30 #ifndef _GLIBCXX_ALIGN_H 31 #define _GLIBCXX_ALIGN_H 1 39 namespace std _GLIBCXX_VISIBILITY(default)
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
62 align(
size_t __align,
size_t __size,
void*& __ptr,
size_t& __space) noexcept
66 const auto __intptr =
reinterpret_cast<uintptr_t
>(__ptr);
67 const auto __aligned = (__intptr - 1u + __align) & -__align;
68 const auto __diff = __aligned - __intptr;
69 if (__diff > (__space - __size))
74 return __ptr =
reinterpret_cast<void*
>(__aligned);
78 #if __cplusplus > 201703L 79 #define __cpp_lib_assume_aligned 201811L 90 template<
size_t _Align,
class _Tp>
91 [[nodiscard,__gnu__::__always_inline__]]
93 assume_aligned(_Tp* __ptr) noexcept
95 static_assert(std::has_single_bit(_Align));
96 if (std::is_constant_evaluated())
102 _GLIBCXX_DEBUG_ASSERT((uintptr_t)__ptr % _Align == 0);
103 return static_cast<_Tp*
>(__builtin_assume_aligned(__ptr, _Align));
108 _GLIBCXX_END_NAMESPACE_VERSION
void * align(size_t __align, size_t __size, void *&__ptr, size_t &__space) noexcept
Fit aligned storage in buffer.
ISO C++ entities toplevel namespace is std.