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

DRApplied toBehavior as publishedCorrect behavior
LWG 299(N3066)C++98the return type of *a– wasrequired to be convertible to Tchanged the returntype to reference[1]
LWG 383C++98b was required to be dereferenceable after –aa is required to be dereferenceable instead
LWG 1212(N3066)C++98the return type of *a– did not match the returntype of *a++ required by LegacyForwardIteratorchanged the returntype to reference

# See also