std::align

From Cppreference

Jump to: navigation, search
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

(keyword)
(keyword)
defines the type suitable for use as uninitialized storage for types of given size
(class template)