[#BloombergLP-bslma-AutoDeallocator]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::AutoDeallocator
:relfileprefix: ../../
:mrdocs:

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&period; 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&period; Note that when the length of this object is non&hyphen;zero, it must refer to a non&hyphen;null array of memory blocks&period;

== Synopsis

Declared in `&lt;bslma&lowbar;autodeallocator&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALLOCATOR&gt;
class AutoDeallocator;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/AutoDeallocator/2constructor-080.adoc[`AutoDeallocator`]         [.small]#[constructor]#
| Create an auto deallocator to manage a sequence of memory blocks&period;
| xref:BloombergLP/bslma/AutoDeallocator/2destructor.adoc[`&#126;AutoDeallocator`] [.small]#[destructor]#
| Destroy this range proctor and deallocate the contiguous sequence of memory blocks it manages (if any) by invoking the `deallocate` method of the allocator (or pool) supplied at construction on each memory block&period; Note that the order in which the managed memory blocks are deallocated is undefined&period;
| xref:BloombergLP/bslma/AutoDeallocator/length.adoc[`length`] 
| Return the (signed) length of the sequence of memory blocks managed by this proctor&period;
| xref:BloombergLP/bslma/AutoDeallocator/operator_inc.adoc[`operator&plus;&plus;`] 
| Increase by one the (signed) length of the sequence of memory blocks managed by this range proctor&period; The behavior is undefined unless the origin of the sequence of memory blocks managed by this proctor is non&hyphen;zero&period; The behavior is undefined unless the origin or this range proctor is non&hyphen;zero&period; Note that if the length of this proctor is currently negative, the number of managed memory blocks will decrease by one, whereas if the length is non&hyphen;negative, the number of managed memory blocks will increase by one&period;
| xref:BloombergLP/bslma/AutoDeallocator/operator_dec.adoc[`operator&hyphen;&hyphen;`] 
| Decrease by one the (signed) length of the sequence of memory blocks managed by this range proctor&period; The behavior is undefined unless the origin of the sequence of memory blocks managed by this proctor is non&hyphen;zero&period; The behavior is undefined unless the origin or this range proctor is non&hyphen;zero&period; Note that if the length of this proctor is currently positive, the number of managed memory blocks will decrease by one, whereas if the length is non&hyphen;positive, the number of managed memory blocks will increase by one&period;
| xref:BloombergLP/bslma/AutoDeallocator/release.adoc[`release`] 
| Release from management the sequence of memory blocks currently managed by this range proctor by setting the length of the managed sequence to 0&period; All memory blocks currently under management will become unmanaged (i&period;e&period;, when the proctor goes out of scope and it was not assigned another sequence of memory blocks to manage by invoking `reset`, no memory blocks will be deallocated)&period; If no memory blocks are currently being managed, this method has no effect&period; Note that the origin is not affected&period;
| xref:BloombergLP/bslma/AutoDeallocator/reset-01.adoc[`reset`] 
| Set the specified `origin` as the origin of the sequence of memory blocks to be managed by this range proctor&period; The behavior is undefined unless `origin` is non&hyphen;zero&period; Note that the length of the sequence of memory blocks managed by this proctor is not affected, and `setLength` should be invoked if the managed range is different from the previously managed sequence of memory blocks&period; Also note that this method releases any previously&hyphen;managed memory blocks from management (without deallocating them), and so may be called with or without having called `release` when reusing this object&period;
| xref:BloombergLP/bslma/AutoDeallocator/setLength.adoc[`setLength`] 
| Set the (signed) length of the sequence of memory blocks managed by this range proctor to the specified `length`&period; The behavior is undefined unless the origin of this range proctor is non&hyphen;zero&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
