table of contents
| std::is_sufficiently_aligned(3) | C++ Standard Libary | std::is_sufficiently_aligned(3) |
NAME¶
std::is_sufficiently_aligned - std::is_sufficiently_aligned
Synopsis¶
Defined in header <memory> template< std::size_t N, class T > (since C++26) bool is_sufficiently_aligned( T* ptr );
Checks whether the pointer ptr points to an object whose alignment has a value of at least N.
The behavior is undefined if ptr does not point to an object of type T (ignoring cv-qualification at every level).
Return value¶
true if ptr points to an object that has alignment at least N; otherwise false.
Exceptions¶
Throws nothing.
Notes¶
std::is_sufficiently_aligned can be used as a precondition to std::assume_aligned.
Feature-test macro Value Std Feature __cpp_lib_is_sufficiently_aligned
202411L (C++26) std::is_sufficiently_aligned
Possible implementation¶
template<std::size_t N, class T> bool
is_sufficiently_aligned(T* ptr) {
return std::bit_cast<std::uintptr_t>(ptr) % N == 0; }
Example¶
This section is incomplete
Reason: no example
See also¶
alignof (C++11) queries alignment requirements of a type
(operator)
specifies that the storage for the variable should be aligned by alignas
(C++11) specific amount
(specifier) aligned_storage defines the type suitable for use as
uninitialized storage for types (since C++11) of given size
(deprecated in C++23) (class template) align aligns a pointer in a
buffer (C++11) (function) aligned_accessor a type for aligned
access to elements of mdspan (C++26) (class template)
| 2026.11.10 | http://cppreference.com |