29#ifndef _ALIGNED_BUFFER_H
30#define _ALIGNED_BUFFER_H 1
33#pragma GCC system_header
36#if __cplusplus >= 201103L
48 template<
typename _Tp>
49 struct __aligned_membuf
57 struct _Tp2 { _Tp _M_t; };
58 alignas(__alignof__(_Tp2::_M_t))
62 unsigned char _M_storage[
sizeof(_Tp)];
64 __aligned_membuf() =
default;
67 __aligned_membuf(std::nullptr_t) { }
71 {
return static_cast<void*
>(&_M_storage); }
74 _M_addr() const noexcept
75 {
return static_cast<const void*
>(&_M_storage); }
79 {
return static_cast<_Tp*
>(_M_addr()); }
82 _M_ptr() const noexcept
83 {
return static_cast<const _Tp*
>(_M_addr()); }
86#if _GLIBCXX_INLINE_VERSION
87 template<
typename _Tp>
88 using __aligned_buffer = __aligned_membuf<_Tp>;
95 template<
typename _Tp>
96 struct __aligned_buffer
99 alignas(__alignof__(_Tp))
unsigned char _M_storage[
sizeof(_Tp)];
101 __aligned_buffer() =
default;
104 __aligned_buffer(std::nullptr_t) { }
109 return static_cast<void*
>(&_M_storage);
113 _M_addr() const noexcept
115 return static_cast<const void*
>(&_M_storage);
120 {
return static_cast<_Tp*
>(_M_addr()); }
123 _M_ptr() const noexcept
124 {
return static_cast<const _Tp*
>(_M_addr()); }
GNU extensions for public use.