[#BloombergLP-bsls-Alignment]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::Alignment
:relfileprefix: ../../
:mrdocs:

This `struct` provides a namespace for enumerating the set of strategies for aligning arbitrary blocks of memory&period;

== Synopsis

Declared in `&lt;bsls&lowbar;alignment&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
struct Alignment;
----

== Types

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/Alignment/Align.adoc[`Align`] 
| `struct` with most stringent alignment requirement&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/Alignment/MaxAlignedType.adoc[`MaxAlignedType`] 
| Primitive type with most stringent alignment requirement&period;
|===


== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/Alignment/_04enum.adoc[`Unnamed enum`] 
| Define the minimum alignment that satisfies all types&period;
| xref:BloombergLP/bsls/Alignment/Strategy.adoc[`Strategy`] 
| Types of alignment strategy&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/Alignment/calculateAlignmentFromSize.adoc[`calculateAlignmentFromSize`] 
| Calculate a usable alignment for an object of specified `size` bytes in the absence of compile&hyphen;time knowledge of the object&apos;s alignment requirements&period; Return the largest power of two that evenly divides size, up to a maximum of `MAX&lowbar;ALIGNMENT`&period; It is guaranteed that an object of `size` bytes can be safely aligned on this return value&period; Depending on the machine architecture and compiler options, the returned alignment may be more than required for two reasons&colon; &grave; 1&period; The object may be composed entirely of elements, such as &apos;char&apos;, which have minimal alignment restrictions&period;
| xref:BloombergLP/bsls/Alignment/calculateAlignmentOffset.adoc[`calculateAlignmentOffset`] 
| Return the smallest non&hyphen;negative offset in bytes that, when added to the specified `address`, yields the specified `alignment`&period; The behavior is undefined unless `0 &lt; alignment` and `alignment` is a power of 2&period;
| xref:BloombergLP/bsls/Alignment/is2ByteAligned.adoc[`is2ByteAligned`] 
| Return `true` if the specified `address` is aligned on a 2&hyphen;byte boundary (i&period;e&period;, the integer value of `address` is divisible by 2), and `false` otherwise&period;
| xref:BloombergLP/bsls/Alignment/is4ByteAligned.adoc[`is4ByteAligned`] 
| Return `true` if the specified `address` is aligned on a 4&hyphen;byte boundary (i&period;e&period;, the integer value of `address` is divisible by 4), and `false` otherwise&period;
| xref:BloombergLP/bsls/Alignment/is8ByteAligned.adoc[`is8ByteAligned`] 
| Return `true` if the specified `address` is aligned on an 8&hyphen;byte boundary (i&period;e&period;, the integer value of `address` is divisible by 8), and `false` otherwise&period;
| xref:BloombergLP/bsls/Alignment/toAscii.adoc[`toAscii`] 
| Return the string representation of the specified enumerator `value`&period; The string representation of `value` matches its corresponding enumerator name with the &quot;BSLS&lowbar;&quot; prefix elided&period; For example&colon; &grave; bsl&colon;&colon;cout &lt;&lt; Alignment&colon;&colon;toAscii(Alignment&colon;&colon;BSLS&lowbar;NATURAL)&semi; &grave; will print the following on standard output&colon; &grave; NATURAL &grave;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
