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
54 struct _Tp2 { _Tp _M_t; };
56 alignas(__alignof__(_Tp2::_M_t))
unsigned char _M_storage[
sizeof(_Tp)];
58 __aligned_membuf() =
default;
61 __aligned_membuf(std::nullptr_t) { }
65 {
return static_cast<void*>(&_M_storage); }
68 _M_addr() const noexcept
69 {
return static_cast<const void*>(&_M_storage); }
73 {
return static_cast<_Tp*>(_M_addr()); }
76 _M_ptr() const noexcept
77 {
return static_cast<const _Tp*>(_M_addr()); }
80 #if _GLIBCXX_INLINE_VERSION 81 template<
typename _Tp>
82 using __aligned_buffer = __aligned_membuf<_Tp>;
89 template<
typename _Tp>
90 struct __aligned_buffer
96 __aligned_buffer() =
default;
99 __aligned_buffer(std::nullptr_t) { }
104 return static_cast<void*>(&_M_storage);
108 _M_addr() const noexcept
110 return static_cast<const void*>(&_M_storage);
115 {
return static_cast<_Tp*>(_M_addr()); }
118 _M_ptr() const noexcept
119 {
return static_cast<const _Tp*>(_M_addr()); }
GNU extensions for public use.