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's range of valid elements; if the count is non-zero at destruction, the destructor destroys the elements in the range [d_deque_p->end() .. d_deque_p->end() + d_count)], or the range [d_deque_p->begin() - d_count .. d_deque_p->begin())], depending on whether this proctor guards the back or front. This guard is used to undo element constructors in the event of an exception. It is up to the client code to increment the count whenever a new element is constructed and to decrement the count whenever d_start or d_finish of the guarded deque is moved to incorporate more elements.
Declared in <bslstl_deque.h>
template<
class VALUE_TYPE,
class ALLOCATOR>
class Deque_Guard;
| Name | Description |
|---|---|
Deque_Guard [constructor] | Initializes object to guard 0 items from the specified deque. This guards either the tail or the head, as determined by the specified isTail boolean. |
~Deque_Guard [destructor] | Call the (template parameter) VALUE_TYPE destructor on objects in the range [d.end() .. d.end() + count())] if isTail was specified as true during construction, or [d.start() - count() .. d.start()] if isTail was specified as false during construction, where d is the deque used to construct this guard. |
begin | Return a pointer after the first item in the guarded range. |
count | Return the current count maintained by this guard. |
end | Return a pointer after the last item in the guarded range. |
operator++ | Increment the count of this guard, and return the new count. |
operator-- | Decrement the count of this guard, and return the new count. |
release | Set the count of this guard to 0. Note that this guard's destructor will do nothing if count is not incremented again after this call. |