BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bsl::memory_resource Class Referenceabstract

#include <bslma_memoryresource.h>

Inheritance diagram for bsl::memory_resource:
bslma::Allocator bslma::AllocatorAdaptor_Imp< STL_ALLOC::template rebind< char >::other > ball::CountingAllocator bdlma::AlignedAllocator bdlma::AligningAllocator bdlma::ConcurrentAllocatorAdapter bdlma::ConcurrentPoolAllocator bdlma::CountingAllocator bdlma::GuardingAllocator bdlma::HeapBypassAllocator bdlma::ManagedAllocator bslma::AllocatorAdaptor_Imp< STL_ALLOC > bslma::BufferAllocator bslma::MallocFreeAllocator bslma::ManagedAllocator bslma::NewDeleteAllocator bslma::TestAllocator

Public Member Functions

 memory_resource () BSLS_KEYWORD_DEFAULT
 
 memory_resource (const memory_resource &) BSLS_KEYWORD_DEFAULT
 
virtual ~memory_resource ()
 
memory_resourceoperator= (const memory_resource &) BSLS_KEYWORD_DEFAULT
 
BSLA_NODISCARD void * allocate (size_t bytes, size_t alignment=k_MAX_ALIGN)
 
void deallocate (void *p, size_t bytes, size_t alignment=k_MAX_ALIGN)
 
bool is_equal (const memory_resource &other) const BSLS_KEYWORD_NOEXCEPT
 

Constructor & Destructor Documentation

◆ memory_resource() [1/2]

bsl::memory_resource::memory_resource ( )

Create this object. Has no effect other than to begin its lifetime.

◆ memory_resource() [2/2]

bsl::memory_resource::memory_resource ( const memory_resource )

◆ ~memory_resource()

bsl::memory_resource::~memory_resource ( )
inlinevirtual

Destroy this object. Has no effect other than to end its lifetime.

Member Function Documentation

◆ allocate()

void * bsl::memory_resource::allocate ( size_t  bytes,
size_t  alignment = k_MAX_ALIGN 
)
inline

Return the (non-null) address of a block of memory suitable for holding an object having at least the specified bytes and alignment. If this memory resource is unable to fulfill the request, i.e., because bytes or alignment is too large, then throw bad_alloc or other suitable exception.

Precondition
The behavior is undefined unless alignment is a power of two.
Note
Note that this function calls the derived-class implementation of do_allocate.

◆ deallocate()

void bsl::memory_resource::deallocate ( void *  p,
size_t  bytes,
size_t  alignment = k_MAX_ALIGN 
)
inline

Deallocate the block of memory at the specified address p and having the specified bytes and alignment by returning it to the derived-class memory resource.

Precondition
The behavior is undefined unless p was allocated from this resource using the same size and alignment and has not yet been deallocated.
Note
Note that this function calls the derived-class implementation of do_deallocate.

◆ is_equal()

bool bsl::memory_resource::is_equal ( const memory_resource other) const
inline

Return true if memory allocated from this resource can be deallocated from the specified other resource and vice-versa; otherwise return false.

Note
Note that this function calls the derived-class implementation of do_is_equal.

◆ operator=()

memory_resource & bsl::memory_resource::operator= ( const memory_resource )

Return a modifiable reference to this object.


The documentation for this class was generated from the following file: