C++ named requirements: LegacyInputIterator

A LegacyInputIterator is a LegacyIterator that can read from the pointed-to element. LegacyInputIterators only guarantee validity for single pass algorithms: once a LegacyInputIterator i has been incremented, all copies of its previous value may be invalidated.

# Declarations

template<class I>
concept __LegacyInputIterator =
__LegacyIterator<I> && std::equality_comparable<I> && requires(I i)
{
typename std::incrementable_traits<I>::difference_type;
typename std::indirectly_readable_traits<I>::value_type;
typename std::common_reference_t<std::iter_reference_t<I>&&,
typename std::indirectly_readable_traits<I>::value_type&>;
*i++;
typename std::common_reference_t<decltype(*i++)&&,
typename std::indirectly_readable_traits<I>::value_type&>;
requires std::signed_integral<typename std::incrementable_traits<I>::difference_type>;
};

# Notes

For an input iterator X that is not a LegacyForwardIterator, std::iterator_traits::reference does not have to be a reference type: dereferencing an input iterator may return a proxy object or std::iterator_traits::value_type itself by value (as in the case of std::istreambuf_iterator).

For the definition of std::iterator_traits, the following exposition-only concept is defined.

concept __LegacyInputIterator = __LegacyIterator && std::equality_comparable && requires(I i) { typename std::incrementable_traits::difference_type; typename std::indirectly_readable_traits::value_type; typename std::common_reference_t<std::iter_reference_t&&, typename std::indirectly_readable_traits::value_type&>; *i++; typename std::common_reference_t<decltype(*i++)&&, typename std::indirectly_readable_traits::value_type&>; requires std::signed_integral<typename std::incrementable_traits::difference_type>;

where the exposition-only concept __LegacyIterator is described in LegacyIterator.

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 98C++98the return type of *i++ was required to be Tit can be any type convertible to T
LWG 2114(P2167R3)C++98convertibility to bool was too weak toreflect the expectation of implementationsrequirements strengthened

# See also