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

Pure abstract protocol for clients and suppliers of raw memory&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class Allocator
    : public std::pmr::memory&lowbar;resource
----

== Description

This protocol class provides a pure abstract interface and contract for clients and suppliers of raw memory&period; If the requested memory cannot be returned, the contract requires that an `std&colon;&colon;bad&lowbar;alloc` exception be thrown&period; Note that memory is guaranteed to be sufficiently aligned for any object of the requested size on the current platform, which may be less than the maximal alignment guarantee afforded by global `operator new`&period;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `std::pmr::memory&lowbar;resource`
| 
|===

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/Allocator/size_type.adoc[`size&lowbar;type`] 
| Alias for an unsigned integral type capable of representing the number of bytes in this platform&apos;s virtual address space&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/Allocator/2destructor.adoc[`&#126;Allocator`] [.small]#[destructor]# [.small]#[virtual]#
| Destroy this allocator&period;
| xref:BloombergLP/bslma/Allocator/operator_assign.adoc[`operator&equals;`] 
| 
| xref:BloombergLP/bslma/Allocator/allocate-03b.adoc[`allocate`] 
| Return a newly allocated block of memory of at least `size` bytes&period;
| xref:BloombergLP/bslma/Allocator/deallocate-04.adoc[`deallocate`] 
| Return the memory block at `address` to this allocator&period;
| xref:BloombergLP/bslma/Allocator/deleteObject-09.adoc[`deleteObject`] 
| `deleteObject` overloads
| xref:BloombergLP/bslma/Allocator/deleteObjectRaw-06f.adoc[`deleteObjectRaw`] 
| `deleteObjectRaw` overloads
| xref:BloombergLP/bslma/Allocator/is_equal.adoc[`is&lowbar;equal`] 
| 
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/Allocator/throwBadAlloc.adoc[`throwBadAlloc`] 
| Throw `std&colon;&colon;bad&lowbar;alloc` or abort the program&period;
|===


== Protected Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/Allocator/do_allocate.adoc[`do&lowbar;allocate`]  [.small]#[virtual]#
| Return a newly allocated block of at least `bytes` with `alignment`&period;
| xref:BloombergLP/bslma/Allocator/do_deallocate.adoc[`do&lowbar;deallocate`]  [.small]#[virtual]#
| Return the memory block at `p` having `bytes` and `alignment`&period;
| xref:BloombergLP/bslma/Allocator/do_is_equal.adoc[`do&lowbar;is&lowbar;equal`]  [.small]#[virtual]#
| Return whether this allocator can exchange memory with `other`&period;
|===


== Derived Classes

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlma/AlignedAllocator.adoc[`AlignedAllocator`] 
| Protocol for clients and suppliers of raw aligned memory&period;
| xref:BloombergLP/bdlma/AligningAllocator.adoc[`AligningAllocator`] 
| Allocator wrapper that guarantees a specified minimum alignment&period;
| xref:BloombergLP/bslma/BufferAllocator.adoc[`BufferAllocator`] 
| Concrete buffer allocator that allocates from a user&hyphen;supplied fixed&hyphen;size buffer&period;
| xref:BloombergLP/bdlma/ConcurrentAllocatorAdapter.adoc[`ConcurrentAllocatorAdapter`] 
| Thread&hyphen;enabled adapter that synchronizes access to a decorated allocator&period;
| xref:BloombergLP/bdlma/ConcurrentPoolAllocator.adoc[`ConcurrentPoolAllocator`] 
| Thread&hyphen;safe allocator that manages pooled memory blocks of uniform size&period;
| xref:BloombergLP/ball/CountingAllocator.adoc[`CountingAllocator`] 
| This class maintains a count of the total number of allocated bytes&period;
| xref:BloombergLP/bdlma/CountingAllocator.adoc[`CountingAllocator`] 
| Concrete allocator that counts bytes currently in use and ever allocated&period;
| xref:BloombergLP/bdlma/GuardingAllocator.adoc[`GuardingAllocator`] 
| Concrete thread&hyphen;safe guarding allocator that adjoins a protected guard page to each allocated block&period;
| xref:BloombergLP/bdlma/HeapBypassAllocator.adoc[`HeapBypassAllocator`] 
| Memory allocator that obtains storage directly from virtual memory&period;
| xref:BloombergLP/bslma/MallocFreeAllocator.adoc[`MallocFreeAllocator`] 
| This class provides direct access to the system&hyphen;supplied (native) global `std&colon;&colon;malloc` and `std&colon;&colon;free`&period;
| xref:BloombergLP/bdlma/ManagedAllocator.adoc[`ManagedAllocator`] 
| Protocol for allocators that support releasing all allocated memory&period;
| xref:BloombergLP/bslma/ManagedAllocator.adoc[`ManagedAllocator`] 
| Protocol for allocators that support releasing all allocated memory&period;
| xref:BloombergLP/bslma/NewDeleteAllocator.adoc[`NewDeleteAllocator`] 
| Concrete allocator adapting global `operator new` and `operator delete`&period;
| xref:BloombergLP/bslma/TestAllocator.adoc[`TestAllocator`] 
| Concrete test allocator that tracks memory usage for testing&period;
|===


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