[#BloombergLP-bslma-Default] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::Default :relfileprefix: ../../ :mrdocs: Provide access to the process‐wide default and global allocators. == Synopsis Declared in `<bslma_default.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Default/allocator.adoc[`allocator`] | Return `basicAllocator`, or the default allocator if it is 0. | xref:BloombergLP/bslma/Default/defaultAllocator.adoc[`defaultAllocator`] | Return the address of the default allocator and lock it. | xref:BloombergLP/bslma/Default/globalAllocator.adoc[`globalAllocator`] | Return `basicAllocator`, or the global allocator if it is 0. | xref:BloombergLP/bslma/Default/lockDefaultAllocator.adoc[`lockDefaultAllocator`] | Disable all subsequent calls to `setDefaultAllocator`. | xref:BloombergLP/bslma/Default/setDefaultAllocator.adoc[`setDefaultAllocator`] | Set the default allocator unless such calls have been disabled. | xref:BloombergLP/bslma/Default/setDefaultAllocatorRaw.adoc[`setDefaultAllocatorRaw`] | Unconditionally set the address of the default allocator. | xref:BloombergLP/bslma/Default/setGlobalAllocator.adoc[`setGlobalAllocator`] | Unconditionally set the address of the global allocator. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#