Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Function align

boost::alignment::align

Synopsis

// In header: <boost/align/align.hpp>


void * align(std::size_t alignment, std::size_t size, void *& ptr, 
             std::size_t & space);

Description

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 updates ptr to point to the first possible address of such storage and decreases space by the number of bytes used for alignment. Otherwise, the function does nothing.

Note: The function updates its ptr and space arguments so that it can be called repeatedly with possibly different alignment and size arguments for the same buffer.

Parameters:

alignment

Shall be a fundamental alignment value or an extended alignment value, and shall be a power of two.

ptr

Shall point to contiguous storage of at least space bytes.

size

The size in bytes of storage to fit into the buffer.

space

The length of the buffer.

Returns:

A null pointer if the requested aligned buffer would not fit into the available space, otherwise the adjusted value of ptr.


PrevUpHomeNext