| 1234567891011121314151617181920212223242526272829303132 |
- export module Core.AlignedData;
- export import Core.Types;
- export namespace Core {
- template<size_t SIZE, size_t ALIGNMENT>
- class alignas(ALIGNMENT) AlignedData final {
- char buffer[SIZE] = {};
- public:
- template<typename T>
- constexpr T* as() noexcept {
- return reinterpret_cast<T*>(this);
- }
- template<typename T>
- constexpr const T* as() const noexcept {
- return reinterpret_cast<T*>(this);
- }
- static consteval size_t getSize() noexcept {
- return SIZE;
- }
- static consteval size_t getAlignment() noexcept {
- return ALIGNMENT;
- }
- };
- template<typename T>
- using AlignedType = AlignedData<sizeof(T), alignof(T)>;
- }
|