Proctor that automatically deallocates a managed object on destruction.

Synopsis

Declared in <bslma_deallocateobjectproctor.h>

template<
    class ALLOCATOR,
    class TYPE = ALLOCATOR::value_type>
class DeallocateObjectProctor;

Description

This class implements a proctor that, unless its release method has previously been invoked, automatically deallocates a managed object upon destruction by invoking the deallocate method of an allocator (or pool) of parameterized ALLOCATOR type supplied to it at construction. The managed object of parameterized TYPE must be memory that was provided by this 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 a deallocate method with a single 'void *' parameter, i.e., the same deallocation interface as bslma::Allocator.

Member Functions

Name

Description

DeallocateObjectProctor [constructor]

Constructors

~DeallocateObjectProctor [destructor]

Deallocate the managed objects, if any. Note that the managed objects' destructors are not invoked.

ptr

Return the address of the currently managed objects, if engaged; otherwise return a null pointer.

release

Disengage this allocator and return a pointer to the formerly managed object(s).

reset

Reset this proctor to manage a different set of objects.

Created with MrDocs