4#include "../Foundation/PrimitiveTypes.h"
9template <
typename T,
size_t E,
size_t R = sizeof(T)>
10void static_assert_size()
12 static_assert(R <= E,
"Size mismatch");
16#pragma GCC diagnostic push
17#pragma GCC diagnostic ignored "-Wstringop-overflow="
27template <
int N,
int Alignment = alignof(
void*)>
41 static_assert_size<T, N>();
42 static_assert(
alignof(T) <= Alignment,
"Increase Alignment of AlignedStorage");
43 return *
reinterpret_cast<T*
>(bytes);
57 static_assert_size<T, N>();
58 static_assert(
alignof(T) <= Alignment,
"Increase Alignment of AlignedStorage");
59 return *
reinterpret_cast<const T*
>(bytes);
63 alignas(Alignment)
char bytes[N] = {0};
66SC_COMPILER_EXTERN template struct SC_COMPILER_EXPORT AlignedStorage<6 *
sizeof(
void*)>;
70#pragma GCC diagnostic pop
#define SC_COMPILER_EXTERN
Define compiler-specific export macros for DLL visibility.
Definition Compiler.h:74
A buffer of bytes with given alignment.
Definition AlignedStorage.h:29
T & reinterpret_as()
Access wanted OS Handle with it's actual type.
Definition AlignedStorage.h:39
const T & reinterpret_as() const
Access wanted OS Handle with it's actual type.
Definition AlignedStorage.h:55