[#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. == Synopsis Declared in `<bslma_allocator.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class Allocator : public std::pmr::memory_resource ---- == Description This protocol class provides a pure abstract interface and contract for clients and suppliers of raw memory. If the requested memory cannot be returned, the contract requires that an `std::bad_alloc` exception be thrown. 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`. == Base Classes [cols="1,4"] |=== | Name| Description | `std::pmr::memory_resource` | |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Allocator/size_type.adoc[`size_type`] | Alias for an unsigned integral type capable of representing the number of bytes in this platform's virtual address space. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Allocator/2destructor.adoc[`~Allocator`] [.small]#[destructor]# [.small]#[virtual]# | Destroy this allocator. | xref:BloombergLP/bslma/Allocator/operator_assign.adoc[`operator=`] | | xref:BloombergLP/bslma/Allocator/allocate-03b.adoc[`allocate`] | Return a newly allocated block of memory of at least `size` bytes. | xref:BloombergLP/bslma/Allocator/deallocate-04.adoc[`deallocate`] | Return the memory block at `address` to this allocator. | 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_equal`] | |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Allocator/throwBadAlloc.adoc[`throwBadAlloc`] | Throw `std::bad_alloc` or abort the program. |=== == Protected Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Allocator/do_allocate.adoc[`do_allocate`] [.small]#[virtual]# | Return a newly allocated block of at least `bytes` with `alignment`. | xref:BloombergLP/bslma/Allocator/do_deallocate.adoc[`do_deallocate`] [.small]#[virtual]# | Return the memory block at `p` having `bytes` and `alignment`. | xref:BloombergLP/bslma/Allocator/do_is_equal.adoc[`do_is_equal`] [.small]#[virtual]# | Return whether this allocator can exchange memory with `other`. |=== == Derived Classes [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlma/AlignedAllocator.adoc[`AlignedAllocator`] | Protocol for clients and suppliers of raw aligned memory. | xref:BloombergLP/bdlma/AligningAllocator.adoc[`AligningAllocator`] | Allocator wrapper that guarantees a specified minimum alignment. | xref:BloombergLP/bslma/BufferAllocator.adoc[`BufferAllocator`] | Concrete buffer allocator that allocates from a user‐supplied fixed‐size buffer. | xref:BloombergLP/bdlma/ConcurrentAllocatorAdapter.adoc[`ConcurrentAllocatorAdapter`] | Thread‐enabled adapter that synchronizes access to a decorated allocator. | xref:BloombergLP/bdlma/ConcurrentPoolAllocator.adoc[`ConcurrentPoolAllocator`] | Thread‐safe allocator that manages pooled memory blocks of uniform size. | xref:BloombergLP/ball/CountingAllocator.adoc[`CountingAllocator`] | This class maintains a count of the total number of allocated bytes. | xref:BloombergLP/bdlma/CountingAllocator.adoc[`CountingAllocator`] | Concrete allocator that counts bytes currently in use and ever allocated. | xref:BloombergLP/bdlma/GuardingAllocator.adoc[`GuardingAllocator`] | Concrete thread‐safe guarding allocator that adjoins a protected guard page to each allocated block. | xref:BloombergLP/bdlma/HeapBypassAllocator.adoc[`HeapBypassAllocator`] | Memory allocator that obtains storage directly from virtual memory. | xref:BloombergLP/bslma/MallocFreeAllocator.adoc[`MallocFreeAllocator`] | This class provides direct access to the system‐supplied (native) global `std::malloc` and `std::free`. | xref:BloombergLP/bdlma/ManagedAllocator.adoc[`ManagedAllocator`] | Protocol for allocators that support releasing all allocated memory. | xref:BloombergLP/bslma/ManagedAllocator.adoc[`ManagedAllocator`] | Protocol for allocators that support releasing all allocated memory. | xref:BloombergLP/bslma/NewDeleteAllocator.adoc[`NewDeleteAllocator`] | Concrete allocator adapting global `operator new` and `operator delete`. | xref:BloombergLP/bslma/TestAllocator.adoc[`TestAllocator`] | Concrete test allocator that tracks memory usage for testing. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#