[#BloombergLP-bslma-Default]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::Default
:relfileprefix: ../../
:mrdocs:

Provide access to the process&hyphen;wide default and global allocators&period;

== Synopsis

Declared in `&lt;bslma&lowbar;default&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class Default;
----

== Description

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

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

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&period;

== 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&period;
| xref:BloombergLP/bslma/Default/defaultAllocator.adoc[`defaultAllocator`] 
| Return the address of the default allocator and lock it&period;
| xref:BloombergLP/bslma/Default/globalAllocator.adoc[`globalAllocator`] 
| Return `basicAllocator`, or the global allocator if it is 0&period;
| xref:BloombergLP/bslma/Default/lockDefaultAllocator.adoc[`lockDefaultAllocator`] 
| Disable all subsequent calls to `setDefaultAllocator`&period;
| xref:BloombergLP/bslma/Default/setDefaultAllocator.adoc[`setDefaultAllocator`] 
| Set the default allocator unless such calls have been disabled&period;
| xref:BloombergLP/bslma/Default/setDefaultAllocatorRaw.adoc[`setDefaultAllocatorRaw`] 
| Unconditionally set the address of the default allocator&period;
| xref:BloombergLP/bslma/Default/setGlobalAllocator.adoc[`setGlobalAllocator`] 
| Unconditionally set the address of the global allocator&period;
|===



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