|
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ALegacyBidirectionalIterator is aLegacyForwardIterator that can be moved in both directions (i.e. incremented and decremented).
If aLegacyBidirectionalIteratorit originates from aContainer, thenit'svalue_type is the same as the container's, so dereferencing (*it) obtains the container'svalue_type.
Contents |
The typeIt satisfiesLegacyBidirectionalIterator if
It satisfiesLegacyForwardIteratorAnd, given
Itreference, the type denoted bystd::iterator_traits<It>::referenceThe following expressions must be valid and have their specified effects:
| Expression | Return | Equivalent expression | Notes |
|---|---|---|---|
| --a | It& | Preconditions:
Postconditions:
| |
| a-- | convertible toconst It& | It temp= a; --a; | |
| *a-- | reference |
AmutableLegacyBidirectionalIterator is aLegacyBidirectionalIterator that additionally satisfies theLegacyOutputIterator requirements.
The begin iterator is not decrementable and the behavior is undefined if--container.begin() is evaluated.
A bidirectional iterator does not have to be dereferenceable to be decrementable (in particular, the end iterator is not dereferenceable but is decrementable).
ConceptFor the definition ofstd::iterator_traits, the following exposition-only concept is defined.
where the exposition-only concept | (since C++20) |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 299 (N3066) | C++98 | the return type of*a-- was required to be convertible to T | changed the return type to reference[1] |
| LWG 383 | C++98 | b was required to be dereferenceable after--a | a is required to be dereferenceable instead |
| LWG 1212 (N3066) | C++98 | the return type of*a-- did not match the return type of*a++ required byLegacyForwardIterator | changed the return type to reference |
(C++20) | specifies that aforward_iterator is a bidirectional iterator, supporting movement backwards(concept)[edit] |
| Iterator library | provides definitions for iterators, iterator traits, adaptors, and utility functions |