Created on 2025-07-03.00:00:00 last changed 1 week ago
Proposed resolution:
This wording is relative to N5008.
Modify [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) is `true`.
-10- Preconditions: `p` points to an object `X` of a type similar ([conv.qual]) to `T`.
-11- Returns: `true` if `X` has alignment at least `Alignment`, otherwise `false`. -12- Throws: Nothing.
`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.
In [ptr.align] `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 [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 [ptr.align] p10.History | |||
---|---|---|---|
Date | User | Action | Args |
2025-07-06 10:37:24 | admin | set | messages: + msg14886 |
2025-07-03 00:00:00 | admin | create |