BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslma::DeallocateObjectProctor< ALLOCATOR, TYPE > Class Template Reference

#include <bslma_deallocateobjectproctor.h>

Public Member Functions

 DeallocateObjectProctor (const ALLOCATOR &allocator, PtrType p, std::size_t n=1)
 
 DeallocateObjectProctor (bslmf::MovableRef< DeallocateObjectProctor > original)
 
 ~DeallocateObjectProctor ()
 
PtrType release ()
 
void reset (PtrType p, std::size_t n=1)
 
PtrType ptr () const
 

Detailed Description

template<class ALLOCATOR, class TYPE = typename ALLOCATOR::value_type>
class bslma::DeallocateObjectProctor< ALLOCATOR, TYPE >

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.

See bslma_deallocateobjectproctor

Constructor & Destructor Documentation

◆ DeallocateObjectProctor() [1/2]

template<class ALLOCATOR , class TYPE >
bslma::DeallocateObjectProctor< ALLOCATOR, TYPE >::DeallocateObjectProctor ( const ALLOCATOR &  allocator,
PtrType  p,
std::size_t  n = 1 
)
inline

Create a proctor to manage the optionally specified n objects at the specified p address, which have been allocated from the specified allocator. If p is null, then the created proctor is disengaged (manages no objects). The behavior is undefined if p is non-null but not allocated from allocator or if p does not point to an array of n objects.

◆ DeallocateObjectProctor() [2/2]

template<class ALLOCATOR , class TYPE >
bslma::DeallocateObjectProctor< ALLOCATOR, TYPE >::DeallocateObjectProctor ( bslmf::MovableRef< DeallocateObjectProctor< ALLOCATOR, TYPE > >  original)
inline

This move constructor creates a proctor managing the same object as original. After the move, original is disengaged.

◆ ~DeallocateObjectProctor()

template<class ALLOCATOR , class TYPE >
bslma::DeallocateObjectProctor< ALLOCATOR, TYPE >::~DeallocateObjectProctor ( )
inline

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

Member Function Documentation

◆ ptr()

template<class ALLOCATOR , class TYPE >
DeallocateObjectProctor< ALLOCATOR, TYPE >::PtrType bslma::DeallocateObjectProctor< ALLOCATOR, TYPE >::ptr ( ) const
inline

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

◆ release()

template<class ALLOCATOR , class TYPE >
DeallocateObjectProctor< ALLOCATOR, TYPE >::PtrType bslma::DeallocateObjectProctor< ALLOCATOR, TYPE >::release ( )
inline

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

◆ reset()

template<class ALLOCATOR , class TYPE = typename ALLOCATOR::value_type>
void bslma::DeallocateObjectProctor< ALLOCATOR, TYPE >::reset ( PtrType  p,
std::size_t  n = 1 
)
inline

Release the managed object and reset this proctor to manage the specified p pointer to optionally specified n objects. If p is null, then the proctor will be disenaged. Note that the previously managed objects are not deallocated.


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