Return whether the specified address is aligned to the given boundary.

Synopsis

Declared in <bsls_alignmentutil.h>

static
bool
isAligned(
    void const* address,
    std::size_t alignment);

Description

Return true if the specified address is aligned on the specified alignment boundary (i.e., the numerical value of address is evenly divisible by alignment), and false otherwise. The behavior is undefined unless alignment is a power of 2. Note that this function will true for a null address, regardless of alignment and for a 0 alignment regardless of address.

Return Value

true if address is aligned to alignment, else false

Parameters

Name

Description

address

pointer whose alignment is tested

alignment

alignment boundary, a power of 2

Created with MrDocs