This class implements a proctor that, unless its release method has previously been invoked, automatically deallocates a managed block of memory upon destruction by invoking the deallocate method of an allocator (or pool) of parameterized ALLOCATOR type supplied to it at construction. The managed memory block must have been provided by the supplied allocator (or pool); the allocator (or pool) must remain valid throughout the lifetime of the proctor object. If ALLOCATOR is a non-pointer type, it is assumed to be STL compatible; otherwise it is assumed have the same deallocation interface as bslma::Allocator.
Declared in <bslma_deallocatebytesproctor.h>
template<class ALLOCATOR>
class DeallocateBytesProctor;
| Name | Description |
|---|---|
DeallocateBytesProctor [constructor] | Constructors |
~DeallocateBytesProctor [destructor] | Deallocate the managed memory, if any, without invoking any other destructors. |
ptr | Return the address of the currently managed memory block, if engaged; otherwise return a null pointer. |
release | Disengage this allocator and return a pointer to the formerly managed memory block. |
reset | Release the managed memory and reset this proctor to manage the specified nbytes bytes at the specified p address. Optionally specify the alignment used to allocate p. If p is null, then the proctor is disengaged (manages no memory). The behavior is undefined unless p is null or was allocated with a size of nbytes and alignment of alignment from the same allocator used to construct this proctor. Note that the previously managed block is not deallocated. |