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

Upon construction, an object of this class saves the current default allocator and installs the user&hyphen;specified allocator as the default allocator&period; On destruction, the original default allocator is restored&period; Objects of this class are intended for testing purposes _only_ and are _not_ guaranteed to be safe in production environments&period;

== Synopsis

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

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

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/DefaultAllocatorGuard/2constructor.adoc[`DefaultAllocatorGuard`]         [.small]#[constructor]#
| Create a scoped guard that installs the specified `temporary` allocator as the default allocator&period; Note that the default allocator is automatically restored to the original allocator on destruction&period;
| xref:BloombergLP/bslma/DefaultAllocatorGuard/2destructor.adoc[`&#126;DefaultAllocatorGuard`] [.small]#[destructor]#
| Restore the default allocator that was in place when this scoped guard was created and destroy this guard&period;
|===



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