Informs the implementation that the object ptr points to is aligned to at least N
. The implementation may use this information to generate more efficient code, but it might only make this assumption if the object is accessed via the return value of assume_aligned
.
N
must be a power of 2. The behavior is undefined if ptr does not point to an object of type T
(ignoring cv-qualification at every level), or if the object's alignment is not at least N
.
ptr.
[edit] ExceptionsThrows nothing.
[edit] NotesTo ensure that the program benefits from the optimizations enabled by assume_aligned
, it is important to access the object via its return value:
void f(int* p) { int* p1 = std::assume_aligned<256>(p); // Use p1, not p, to ensure benefit from the alignment assumption. // However, the program has undefined behavior if p is not aligned // regardless of whether p1 is used. }
It is up to the program to ensure that the alignment assumption actually holds. A call to assume_aligned
does not cause the compiler to verify or enforce this.
alignof
(C++11) queries alignment requirements of a type
alignas
(C++11) specifies that the storage for the variable should be aligned by specific amount
(since C++11)(deprecated in C++23)
defines the type suitable for use as uninitialized storage for types of given sizeRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4