This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
is_sufficiently_aligned
Section: 20.2.5 [ptr.align] Status: New Submitter: Damien Lebrun-Grandie Opened: 2025-07-03 Last modified: 2025-07-06
Priority: Not Prioritized
View other active issues in [ptr.align].
View all other issues in [ptr.align].
View all issues with New status.
Discussion:
is_sufficiently_aligned
should mandate that the alignment template argument is a power of two
and that it is greater equal to the byte alignment of its type template argument.
is_sufficiently_aligned
has no Mandates element. It is an
oversight that we realized when implementing P2897R7 into libc++
(in https://github.com/llvm/llvm-project/pull/122603).
The function template was originally proposed as a static member function of the aligned_accessor
class template which has these two Mandates clauses and therefore applied
(see 23.7.3.5.4.1 [mdspan.accessor.aligned.overview] p1). It revision P2897R4,
is_sufficiently_aligned
was moved out the class template definition to become the free function
memory helper that was voted into C++26 but the Mandates were lost in the process.
We propose to correct that oversight and reintroduce the following Mandates clauses right above
20.2.5 [ptr.align] p10.
Proposed resolution:
This wording is relative to N5008.
Modify 20.2.5 [ptr.align] as indicated:
template<size_t Alignment, class T> bool is_sufficiently_aligned(T* ptr);-?- Mandates:
(?.1) —
Alignment
is a power of two, and(?.2) —
Alignment >= alignof(T)
istrue
.-10- Preconditions:
-11- Returns:p
points to an objectX
of a type similar (7.3.6 [conv.qual]) toT
.true
ifX
has alignment at leastAlignment
, otherwisefalse
. -12- Throws: Nothing.