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

#include <bslma_deallocatebytesproctor.h>

Public Member Functions

 DeallocateBytesProctor (const ALLOCATOR &allocator, PtrType p, std::size_t nbytes, std::size_t alignment=k_MAX_ALIGNMENT)
 
 DeallocateBytesProctor (bslmf::MovableRef< DeallocateBytesProctor > original)
 
 ~DeallocateBytesProctor ()
 
PtrType release ()
 
void reset (PtrType p, std::size_t nbytes, std::size_t alignment=k_MAX_ALIGNMENT)
 
PtrType ptr () const
 

Detailed Description

template<class ALLOCATOR>
class bslma::DeallocateBytesProctor< ALLOCATOR >

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.

See bslma_deallocatebytesproctor

Constructor & Destructor Documentation

◆ DeallocateBytesProctor() [1/2]

template<class ALLOCATOR >
bslma::DeallocateBytesProctor< ALLOCATOR >::DeallocateBytesProctor ( const ALLOCATOR &  allocator,
PtrType  p,
std::size_t  nbytes,
std::size_t  alignment = k_MAX_ALIGNMENT 
)
inline

Create a proctor to manage the specified nbytes bytes at the specified p address, which have been allocated from the specified allocator. Optionally specify the alignment used to allocate the bytes. If p is null, then the created proctor is disengaged (manages no memory). The behavior is undefined unless p is null or was allocated from allocator with a size of nbytes and alignment of alignment.

◆ DeallocateBytesProctor() [2/2]

template<class ALLOCATOR >
bslma::DeallocateBytesProctor< ALLOCATOR >::DeallocateBytesProctor ( bslmf::MovableRef< DeallocateBytesProctor< ALLOCATOR > >  original)
inline

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

◆ ~DeallocateBytesProctor()

template<class ALLOCATOR >
bslma::DeallocateBytesProctor< ALLOCATOR >::~DeallocateBytesProctor ( )
inline

Deallocate the managed memory, if any, without invoking any other destructors.

Member Function Documentation

◆ ptr()

template<class ALLOCATOR >
DeallocateBytesProctor< ALLOCATOR >::PtrType bslma::DeallocateBytesProctor< ALLOCATOR >::ptr ( ) const
inline

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

◆ release()

template<class ALLOCATOR >
DeallocateBytesProctor< ALLOCATOR >::PtrType bslma::DeallocateBytesProctor< ALLOCATOR >::release ( )
inline

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

◆ reset()

template<class ALLOCATOR >
void bslma::DeallocateBytesProctor< ALLOCATOR >::reset ( PtrType  p,
std::size_t  nbytes,
std::size_t  alignment = k_MAX_ALIGNMENT 
)
inline

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.


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