This class implements a range proctor that automatically deallocates managed memory blocks.

Synopsis

Declared in <bslma_autodeallocator.h>

template<class ALLOCATOR>
class AutoDeallocator;

Description

This class implements a range proctor that, unless its release method has previously been invoked, automatically deallocates the contiguous sequence of managed memory blocks upon its own destruction by invoking the deallocate method of an allocator (or pool) of parameterized ALLOCATOR type supplied to it at construction. Each of the managed memory blocks must have been supplied by this allocator (or pool), which must remain valid throughout the lifetime of the range proctor. Note that when the length of this object is non‐zero, it must refer to a non‐null array of memory blocks.

Member Functions

Name

Description

AutoDeallocator [constructor]

Create an auto deallocator to manage a sequence of memory blocks.

~AutoDeallocator [destructor]

Destroy this range proctor and deallocate any managed memory blocks.

length

Return the (signed) length of the sequence of memory blocks managed by this proctor.

operator++

Increase by one the (signed) length of the managed memory‐block sequence.

operator‐‐

Decrease by one the (signed) length of the managed memory‐block sequence.

release

Release from management all memory blocks currently managed by this proctor.

reset

Set the origin of the sequence of memory blocks managed by this proctor.

setLength

Set the (signed) length of the managed memory‐block sequence.

Created with MrDocs