BloombergLP::bslma::Default

Provide access to the process-wide default and global allocators.

Synopsis

Declared in <bslma_default.h>

class Default;

Description

This struct is a mechanism with global state, i.e., all state is held in global variables and all functions are class methods. The state consists of two distinct parts that don't influence one another: the default allocator and the global allocator. All addresses are stored without assuming ownership.

The setDefaultAllocator method will only modify the default allocator prior to the default allocator being accessed (by either allocator, defaultAllocator, or lockDefaultAllocator). The global allocator may be freely modified.

Note that only the owner of main (or in testing), where the caller affirmatively takes responsibility for the behavior of all clients of the global allocator, is intended to change the global allocator.

Static Member Functions

NameDescription
allocator Return basicAllocator, or the default allocator if it is 0.
defaultAllocator Return the address of the default allocator and lock it.
globalAllocator Return basicAllocator, or the global allocator if it is 0.
lockDefaultAllocator Disable all subsequent calls to setDefaultAllocator.
setDefaultAllocator Set the default allocator unless such calls have been disabled.
setDefaultAllocatorRaw Unconditionally set the address of the default allocator.
setGlobalAllocator Unconditionally set the address of the global allocator.