[#BloombergLP-bsls-Alignment-calculateAlignmentFromSize] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::xref:BloombergLP/bsls/Alignment.adoc[Alignment]::calculateAlignmentFromSize :relfileprefix: ../../../ :mrdocs: Calculate a usable alignment for an object of specified `size` bytes in the absence of compile‐time knowledge of the object's alignment requirements. Return the largest power of two that evenly divides size, up to a maximum of `MAX_ALIGNMENT`. It is guaranteed that an object of `size` bytes can be safely aligned on this return value. Depending on the machine architecture and compiler options, the returned alignment may be more than required for two reasons: ` 1. The object may be composed entirely of elements, such as 'char', which have minimal alignment restrictions. == Synopsis Declared in `<bsls_alignment.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static int calculateAlignmentFromSize(int size); ---- == Description 2. The architecture may have lenient alignment requirements. Even if this is the case, aligning on a stricter boundary may improve performance. ` The behavior is undefined unless `0 < size`. DEPRECATED: Use `AlignmentUtil::calculateAlignmentFromSize` instead. [.small]#Created with https://www.mrdocs.com[MrDocs]#