[#bsl-Deque_Guard]
= xref:bsl.adoc[bsl]::Deque&lowbar;Guard
:relfileprefix: ../
:mrdocs:

Proctor for uncommitted elements constructed at one end of a deque&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;deque&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VALUE&lowbar;TYPE,
    class ALLOCATOR&gt;
class Deque&lowbar;Guard;
----

== Description

This class provides a proctor that maintains a count of the number of elements constructed at the front or back of a deque, but not yet committed to the deque&apos;s range of valid elements&semi; if the count is non&hyphen;zero at destruction, the destructor destroys the elements in the range `&lsqb;d&lowbar;deque&lowbar;p&hyphen;&gt;end() &period;&period; d&lowbar;deque&lowbar;p&hyphen;&gt;end() &plus; d&lowbar;count)&rsqb;`, or the range `&lsqb;d&lowbar;deque&lowbar;p&hyphen;&gt;begin() &hyphen; d&lowbar;count &period;&period; d&lowbar;deque&lowbar;p&hyphen;&gt;begin())&rsqb;`, depending on whether this proctor guards the back or front&period; This guard is used to undo element constructors in the event of an exception&period; It is up to the client code to increment the count whenever a new element is constructed and to decrement the count whenever `d&lowbar;start` or `d&lowbar;finish` of the guarded deque is moved to incorporate more elements&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/Deque_Guard/2constructor.adoc[`Deque&lowbar;Guard`]         [.small]#[constructor]#
| Create a guard for uncommitted elements at one end of `deque`&period;
| xref:bsl/Deque_Guard/2destructor.adoc[`&#126;Deque&lowbar;Guard`] [.small]#[destructor]#
| Destroy guarded elements that were never committed to the deque&period;
| xref:bsl/Deque_Guard/begin.adoc[`begin`] 
| Return a pointer after the first item in the guarded range&period;
| xref:bsl/Deque_Guard/count.adoc[`count`] 
| Return the current count maintained by this guard&period;
| xref:bsl/Deque_Guard/end.adoc[`end`] 
| Return a pointer after the last item in the guarded range&period;
| xref:bsl/Deque_Guard/operator_inc.adoc[`operator&plus;&plus;`] 
| Increment the count of this guard, and return the new count&period;
| xref:bsl/Deque_Guard/operator_dec.adoc[`operator&hyphen;&hyphen;`] 
| Decrement the count of this guard, and return the new count&period;
| xref:bsl/Deque_Guard/release.adoc[`release`] 
| Set the count of this guard to 0&period; Note that this guard&apos;s destructor will do nothing if count is not incremented again after this call&period;
|===



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