Namespaces
Variants
Views
Actions

std::align

From cppreference.com
 
 
 
 
Defined in header <memory>
void* align( std::size_t alignment,

             std::size_t size,
             void*& ptr,

             std::size_t& space);
(since C++11)

If it is possible to fit size bytes of storage aligned by alignment into the buffer pointed to by ptr with length space, the function modifies ptr to point to the first possible address of such aligned storage and decreases space by the number of bytes used for alignment. If it is impossible (the buffer is too small), align does nothing.

Contents

[edit] Parameters

alignment - the desired alignment
size - the size of the storage to be aligned
ptr - pointer to contiguous storage of at least space bytes
space - the size of the buffer in which to operate

[edit] Return value

The adjusted value of ptr, or null pointer value if the space provided is too small.

[edit] Example

[edit] See also

alignof operator queries alignment requirements of a type (since C++11) [edit]
alignas specifier specifies that the storage for the variable should be aligned by specific amount (C++11) [edit]
defines the type suitable for use as uninitialized storage for types of given size
(class template) [edit]