This class implements a proctor that, unless its release method has previously been invoked, automatically deletes a managed object upon destruction by first invoking the object's destructor, and then 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 have been created using memory provided by this allocator (or pool), which 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.

Synopsis

Declared in <bslma_deleteobjectproctor.h>

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

Member Functions

Name

Description

DeleteObjectProctor [constructor]

Constructors

~DeleteObjectProctor [destructor]

Destroy and deallocate the managed object, if any.

ptr

Return the address of the currently managed object, if engaged; otherwise return null.

release

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

reset

Release the managed object and reset this proctor to manage the specified p object. If p is null, the proctor will be disengaged. Note that the previously managed object is not destroyed or deallocated.

Created with MrDocs