libstdc++
|
#include <type_traits>
Aligned storage.
The member typedef type
is be a POD type suitable for use as uninitialized storage for any object whose size is at most _Len
and whose alignment is a divisor of _Align
.
It is important to use the nested type
as uninitialized storage, not the std::aligned_storage
type itself which is an empty class with 1-byte alignment. So this is correct:
typename std::aligned_storage<sizeof(X), alignof(X)>::type m_xobj;
This is wrong:
std::aligned_storage<sizeof(X), alignof(X)> m_xobj;
In C++14 and later std::aligned_storage_t<sizeof(X), alignof(X)>
can be used to refer to the type
member typedef.
The default value of _Align is supposed to be the most stringent fundamental alignment requirement for any C++ object type whose size is no greater than _Len
(see [basic.align] in the C++ standard).
std::byte[_Len]
declared with alignas(_Align)
. Definition at line 2376 of file type_traits.