29 #ifndef _ALIGNED_BUFFER_H 30 #define _ALIGNED_BUFFER_H 1 32 #pragma GCC system_header 34 #if __cplusplus >= 201103L 46 template<
typename _Tp>
47 struct __aligned_membuf
52 struct _Tp2 { _Tp _M_t; };
54 alignas(__alignof__(_Tp2::_M_t))
unsigned char _M_storage[
sizeof(_Tp)];
56 __aligned_membuf() =
default;
59 __aligned_membuf(std::nullptr_t) { }
63 {
return static_cast<void*
>(&_M_storage); }
66 _M_addr() const noexcept
67 {
return static_cast<const void*
>(&_M_storage); }
71 {
return static_cast<_Tp*
>(_M_addr()); }
74 _M_ptr() const noexcept
75 {
return static_cast<const _Tp*
>(_M_addr()); }
83 template<
typename _Tp>
84 struct __aligned_buffer
85 : std::aligned_storage<sizeof(_Tp), std::alignment_of<_Tp>::value>
88 std::aligned_storage<sizeof(_Tp), std::alignment_of<_Tp>::value>::type
91 __aligned_buffer() =
default;
94 __aligned_buffer(std::nullptr_t) { }
99 return static_cast<void*
>(&_M_storage);
103 _M_addr() const noexcept
105 return static_cast<const void*
>(&_M_storage);
110 {
return static_cast<_Tp*
>(_M_addr()); }
113 _M_ptr() const noexcept
114 {
return static_cast<const _Tp*
>(_M_addr()); }
GNU extensions for public use.