[iterator.concept.sizedsentinel] (original) (raw)

23 Iterators library [iterators]

23.3 Iterator requirements [iterator.requirements]

23.3.4 Iterator concepts [iterator.concepts]

23.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]

template<class S, class I> concept [sized_­sentinel_­for](#concept:sized%5Fsentinel%5Ffor "23.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]") = [sentinel_­for](iterator.concept.sentinel#concept:sentinel%5Ffor "23.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]")<S, I> && !disable_sized_sentinel_for<remove_cv_t<S>, remove_cv_t<I>> && requires(const I& i, const S& s) { { s - i } -> [same_­as](concept.same#concept:same%5Fas "18.4.2 Concept same_­as [concept.same]")<iter_difference_t<I>>;{ i - s } -> [same_­as](concept.same#concept:same%5Fas "18.4.2 Concept same_­as [concept.same]")<iter_difference_t<I>>;};

Let i be an iterator of type I, and sa sentinel of type S such that [i, s) denotes a range.

Let N be the smallest number of applications of ++inecessary to make bool(i == s) be true.

S and I model sized_­sentinel_­for<S, I> only if

template<class S, class I> inline constexpr bool disable_sized_sentinel_for = false;

Remarks: Pursuant to [namespace.std], users may specialize disable_­sized_­sentinel_­forfor cv-unqualified non-array object types S and Iif S and/or I is a program-defined type.

Such specializations shall be usable in constant expressions ([expr.const]) and have type const bool.

[Note 1:

disable_­sized_­sentinel_­for allows use of sentinels and iterators with the library that satisfy but do not in fact model sized_­sentinel_­for.

— _end note_]

[Example 1:

— _end example_]