[#BloombergLP-bslma-AutoDestructor] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::AutoDestructor :relfileprefix: ../../ :mrdocs: This class implements a range proctor that, unless its `release` method has previously been invoked, automatically destroys the contiguous sequence of managed objects upon its own destruction by invoking each object's destructor. If `release` is invoked (see `release`), the proctor will not destroy any objects upon its own destruction (unless `reset` is invoked to assign the proctor another contiguous sequence of objects for management). Note that when the length of this object is non‐zero, it must refer to a non‐null array of objects. == Synopsis Declared in `<bslma_autodestructor.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TYPE> class AutoDestructor; ---- == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/AutoDestructor/2constructor.adoc[`AutoDestructor`] [.small]#[constructor]# | Create a range proctor to manage an array of objects at the specified `origin`. Optionally specify `length` to define its range, which by default is empty (i.e., `length = 0`). The sequence of objects may extend in either direction from `origin`. A positive `length` represents the sequence of objects starting at `origin` and extending "up" to `length` (_not_ including the object at the index position `origin + length`). A negative `length` represents the sequence of objects starting at one position below `origin` and extending "down" to the absolute value of `length` (including the object at index position `origin + length`). If `length` is 0, then this range proctor manages no objects. The behavior is undefined unless both `origin` and `length` are zero, or `origin` is non‐zero and all objects (if any) within the managed range (as defined by `length`) are valid. Note that when `length` is non‐positive, the object at the origin is _not_ managed by this range proctor. For example, if `origin` is at the index position 2, a `length` of 2 signifies that the objects at positions 2 and 3 are managed, whereas a `length` of ‐2 signifies that the objects at positions 0 and 1 are managed: ` length = ‐2 length = 2 |<‐‐‐‐‐>| |<‐‐‐‐‐>| ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ | 0 | 1 | 2 | 3 | 4 | | 0 | 1 | 2 | 3 | 4 | `#=ˆ#=^===^#=ˆ#=' `#=ˆ#=^===^#=ˆ#=' ˆ‐‐‐‐‐‐‐‐‐‐‐‐ origin ˆ‐‐‐‐‐‐‐‐‐‐‐‐ origin ` | xref:BloombergLP/bslma/AutoDestructor/2destructor.adoc[`~AutoDestructor`] [.small]#[destructor]# | Destroy this range proctor along with the contiguous sequence of objects it manages (if any) by invoking the destructor of each (managed) object. Note that the order in which the managed objects are destroyed is undefined. | xref:BloombergLP/bslma/AutoDestructor/length.adoc[`length`] | Return the (signed) length of the sequence of objects managed by this range proctor. | xref:BloombergLP/bslma/AutoDestructor/operator_inc.adoc[`operator++`] | Increase by one the (signed) length of the sequence of objects managed by this range proctor. The behavior is undefined unless the origin of the sequence of objects managed by this proctor is non‐zero. The behavior is undefined unless the origin of this range proctor is non‐zero. Note that if the length of this proctor is currently negative, the number of managed objects will decrease by one, whereas if the length is non‐negative, the number of managed objects will increase by one. | xref:BloombergLP/bslma/AutoDestructor/operator_dec.adoc[`operator‐‐`] | Decrease by one the (signed) length of the sequence of objects managed by this range proctor. The behavior is undefined unless the origin of the sequence of objects managed by this proctor is non‐zero. The behavior is undefined unless the origin of this range proctor is non‐zero. Note that if the length of this proctor is currently positive, the number of managed objects will decrease by one, whereas if the length is non‐positive, the number of managed objects will increase by one. | xref:BloombergLP/bslma/AutoDestructor/release.adoc[`release`] | Release from management the sequence of objects currently managed by this range proctor by setting the length of the managed sequence to 0. All objects currently under management will become unmanaged (i.e., when the proctor goes out of scope and it was not assigned another sequence of objects to manage by invoking `reset`, no objects will be destroyed). If no objects are currently being managed, this method has no effect. Note that the origin is not affected. | xref:BloombergLP/bslma/AutoDestructor/reset.adoc[`reset`] | Set the specified `origin` of the sequence of objects managed by this range proctor. This method does not destroy the previously‐managed objects or affect the length of the sequence managed. The behavior is undefined unless `origin` is non‐zero. Note that `reset` can be called without having previously called `release` provided that `length` is set appropriately before this proctor could be destroyed (e.g., via a thrown exception). | xref:BloombergLP/bslma/AutoDestructor/setLength.adoc[`setLength`] | Set the (signed) length of the sequence of objects managed by this range proctor to the specified `length`. The behavior is undefined unless the origin of this range proctor is non‐zero. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#