|
6572 | 6572 | void undeclare_no_pointers(char* p, size_t n);
|
6573 | 6573 | pointer_safety get_pointer_safety() noexcept;
|
6574 | 6574 |
|
6575 |
| - // \ref{ptr.align}, pointer alignment function |
| 6575 | + // \ref{ptr.align}, pointer alignment |
6576 | 6576 | void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
|
| 6577 | + template<size_t N, class T> |
| 6578 | + [[nodiscard]] constexpr T* assume_aligned(T* ptr); |
6577 | 6579 |
|
6578 | 6580 | // \ref{allocator.tag}, allocator argument tag
|
6579 | 6581 | struct allocator_arg_t { explicit allocator_arg_t() = default; };
|
|
7128 | 7130 | \end{itemdescr}
|
7129 | 7131 |
|
7130 | 7132 |
|
7131 |
| -\rSec2[ptr.align]{Align} |
| 7133 | +\rSec2[ptr.align]{Pointer alignment} |
7132 | 7134 |
|
7133 | 7135 | \indexlibrary{\idxcode{align}}%
|
7134 | 7136 | \begin{itemdecl}
|
|
7166 | 7168 | arguments for the same buffer. \end{note}
|
7167 | 7169 | \end{itemdescr}
|
7168 | 7170 |
|
| 7171 | +\indexlibrary{\idxcode{assume_aligned}}% |
| 7172 | +\begin{itemdecl} |
| 7173 | +template<size_t N, class T> |
| 7174 | + [[nodiscard]] constexpr T* assume_aligned(T* ptr); |
| 7175 | +\end{itemdecl} |
| 7176 | + |
| 7177 | +\begin{itemdescr} |
| 7178 | +\pnum |
| 7179 | +\mandates |
| 7180 | +\tcode{N} is a power of two. |
| 7181 | + |
| 7182 | +\pnum |
| 7183 | +\expects |
| 7184 | +\tcode{ptr} points to an object \tcode{X} of |
| 7185 | +a type similar\iref{conv.qual} to \tcode{T}, |
| 7186 | +where \tcode{X} has alignment \tcode{N}\iref{basic.align}. |
| 7187 | + |
| 7188 | +\pnum |
| 7189 | +\returns |
| 7190 | +\tcode{ptr}. |
| 7191 | + |
| 7192 | +\pnum |
| 7193 | +\throws |
| 7194 | +Nothing. |
| 7195 | + |
| 7196 | +\pnum |
| 7197 | +\begin{note} |
| 7198 | +The alignment assumption on an object \tcode{X} |
| 7199 | +expressed by a call to \tcode{assume_aligned} |
| 7200 | +may result in generation of more efficient code. |
| 7201 | +It is up to the program to ensure that the assumption actually holds. |
| 7202 | +The call does not cause the compiler to verify or enforce this. |
| 7203 | +An implementation might only make the assumption |
| 7204 | +for those operations on \tcode{X} that access \tcode{X} |
| 7205 | +through the pointer returned by \tcode{assume_aligned}. |
| 7206 | +\end{note} |
| 7207 | +\end{itemdescr} |
| 7208 | + |
7169 | 7209 | \rSec2[allocator.tag]{Allocator argument tag}
|
7170 | 7210 |
|
7171 | 7211 | \indexlibrary{\idxcode{allocator_arg_t}}%
|
|
0 commit comments