[#BloombergLP-bsls-AlignmentUtil-calculateAlignmentFromSize] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::xref:BloombergLP/bsls/AlignmentUtil.adoc[AlignmentUtil]::calculateAlignmentFromSize :relfileprefix: ../../../ :mrdocs: Return the natural alignment for a memory block of the specified size. == Synopsis Declared in `<bsls_alignmentutil.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static int calculateAlignmentFromSize(std::size_t size); ---- == Description Return the _natural_ alignment for a memory block of the specified size ‐‐ i.e., the largest power of 2 that evenly divides `size`, up to a maximum of `BSLS_MAX_ALIGNMENT`. It is guaranteed that this alignment will be sufficient for any object having a footprint of `size` bytes on the current platform. The behavior is undefined unless `1 <= size` and `size <= INT_MAX`. Note that, depending on the machine architecture and compiler setting, the returned alignment value may be more restrictive than required for a particular object for two reasons: 1. The object may be composed entirely of elements, such as `char`, that have minimal alignment restrictions, and 2. The architecture and our compiler settings may result in unexpectedly lenient alignment requirements. Also note that aligning on a more restrictive boundary may improve performance. == Return Value natural alignment for a block of `size` bytes == Parameters [cols="1,4"] |=== | Name| Description | *size* | size in bytes of the memory block |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#