std::sentinel_for

Header: <iterator>

The sentinel_for concept specifies the relationship between an input_or_output_iterator type and a semiregular type whose values denote a range. The exposition-only concept __WeaklyEqualityComparableWith is described in equality_comparable.

# Declarations

template< class S, class I >
concept sentinel_for =
std::semiregular<S> &&
std::input_or_output_iterator<I> &&
__WeaklyEqualityComparableWith<S, I>;

(since C++20)

# Notes

A sentinel type and its corresponding iterator type are not required to model equality_comparable_with, because the sentinel type may not be comparable with itself, and they are not required to have a common reference type.

It has been permitted to use a sentinel type different from the iterator type in the range-based for loop since C++17.

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 3453C++20semantic requirements for sentinel_for were too loose for ranges::advancestrengthened