Return the byte offset needed to align the specified address.

Synopsis

Declared in <bsls_alignment.h>

static
int
calculateAlignmentOffset(
    void const* address,
    int alignment);

Description

Return the smallest non‐negative offset in bytes that, when added to the specified address, yields the specified alignment. The behavior is undefined unless 0 < alignment and alignment is a power of 2.

DEPRECATED: Use AlignmentUtil::calculateAlignmentOffset instead.

Return Value

smallest non‐negative offset in bytes

Parameters

Name

Description

address

memory address to align

alignment

required alignment; must be a power of 2

Created with MrDocs