std::experimental::ranges::SizedSentinel

From cppreference.com
< cpp‎ | experimental‎ | ranges
Experimental
Technical Specification
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals TS v2)
Library fundamentals 3 (library fundamentals TS v3)
Extensions for parallelism (parallelism TS)
Extensions for parallelism 2 (parallelism TS v2)
Extensions for concurrency (concurrency TS)
Extensions for concurrency 2 (concurrency TS v2)
Concepts (concepts TS)
Ranges (ranges TS)
Reflection (reflection TS)
Mathematical special functions (special functions TR)
Experimental Non-TS
Pattern Matching
Linear Algebra
std::execution
Contracts
2D Graphics
template < class S, class I >

concept bool SizedSentinel =
    Sentinel<S, I> &&
!ranges:: disable_sized_sentinel < std::remove_cv_t <S>, std::remove_cv_t <I>> &&
    requires( const I& i, const S& s) {
{ s - i } - > Same<ranges:: difference_type_t <I>> && ;
{ i - s } - > Same<ranges:: difference_type_t <I>> && ;

} ;
(1) (ranges TS)
template < class S, class I >
constexpr bool disable_sized_sentinel = false ;
(1) (ranges TS)

The SizedSentinel concept specifies that an object of the iterator type I and an object of the sentinel type S can be subtracted to compute the distance between them in constant time.

Let i be an iterator of type I, and s a sentinel of type S such that [ i s ) denotes a range. Let N be the smallest number of applications of ++i necessary to make bool(i == s) be true. Then SizedSentinel<S, I>

  • If N is representable by ranges::difference_type_t<I>, then s - i is well-defined and equals N
  • If -N is representable by ranges::difference_type_t<I>, then i - s is well-defined and equals -N

The variable template disable_sized_sentinel provides a mechanism for iterators and sentinels that can be subtracted but do not meet the semantic requirements of SizedSentinel to opt out of the concept by specializing the variable template to have the value true

Equality preservation

An expression is equality preserving if it results in equal outputs given equal inputs.

  • The inputs to an expression consist of its operands.
  • The outputs of an expression consist of its result and all operands modified by the expression (if any).

Every expression required to be equality preserving is further required to be stable

Unless noted otherwise, every expression used in a requires-expression

Implicit expression variations

A requires-expression implicit expression variations