C++ named requirements: LegacyBidirectionalIterator
A LegacyBidirectionalIterator is a LegacyForwardIterator that can be moved in both directions (i.e. incremented and decremented).
# Declarations
template<class I>
concept __LegacyBidirectionalIterator =
__LegacyForwardIterator<I> && requires(I i)
{
{ --i } -> std::same_as<I&>;
{ i-- } -> std::convertible_to<const I&>;
{ *i-- } -> std::same_as<std::iter_reference_t<I>>;
};
# Notes
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).
For the definition of std::iterator_traits, the following exposition-only concept is defined.
concept __LegacyBidirectionalIterator = __LegacyForwardIterator && requires(I i) { { –i } -> std::same_as<I&>; { i– } -> std::convertible_to<const I&>; { *i– } -> std::same_as<std::iter_reference_t>;
where the exposition-only concept __LegacyForwardIterator is described in LegacyForwardIterator.
# Defect reports
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 299(N3066) | C++98 | the return type of *a– wasrequired to be convertible to T | changed the returntype 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 returntype of *a++ required by LegacyForwardIterator | changed the returntype to reference |