std::sized_sentinel_for, std::disable_sized_sentinel_for
Defined in header <iterator>


template<class S, class I> concept sized_sentinel_for = 
(1)  (since C++20) 
template<class S, class I> inline constexpr disable_sized_sentinel_for = false; 
(2)  (since C++20) 
sized_sentinel_for
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. disable_sized_sentinel_for
variable template can be used to prevent iterators and sentinels that can be subtracted but do not actually model sized_sentinel_for
from satisfying the concept.The variable template is allowed to be specialized for cvunqualified nonarray object type
S
and I
, as long as at least one of which is a programdefined type. Such specializations shall be usable in constant expressions and have type const bool.[edit] Semantic requirements
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
. sized_sentinel_for<S, I>
is satisfied only if:
 If
n
is representable by std::iter_difference_t<I>, then s  i is welldefined and equalsn
; and  If
n
is representable by std::iter_difference_t<I>, then i  s is welldefined and equalsn
.  Subtraction between
i
ands
has constant time complexity.
[edit] 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).
In specification of standard concepts, operands are defined as the largest subexpressions that include only:
 an idexpression, and
 invocations of std::move, std::forward, and std::declval.
The cvqualification and value category of each operand is determined by assuming that each template type parameter denotes a cvunqualified complete nonarray object type.
Every expression required to be equality preserving is further required to be stable: two evaluations of such an expression with the same input objects must have equal outputs absent any explicit intervening modification of those input objects.
Unless noted otherwise, every expression used in a requiresexpression is required to be equality preserving and stable, and the evaluation of the expression may only modify its nonconstant operands. Operands that are constant must not be modified.
[edit] Implicit expression variations
A requiresexpression that uses an expression that is nonmodifying for some constant lvalue operand also implicitly requires additional variations of that expression that accept a nonconstant lvalue or (possibly constant) rvalue for the given operand unless such an expression variation is explicitly required with differing semantics. These implicit expression variations must meet the same semantic requirements of the declared expression. The extent to which an implementation validates the syntax of the variations is unspecified.