Scroll to navigation

std::sized_sentinel_for,std::disable_sized_sentinel_for(3) C++ Standard Libary std::sized_sentinel_for,std::disable_sized_sentinel_for(3)

NAME

std::sized_sentinel_for,std::disable_sized_sentinel_for - std::sized_sentinel_for,std::disable_sized_sentinel_for

Synopsis


Defined in header <iterator>
template< class S, class I >


concept sized_sentinel_for =
std::sentinel_for<S, I> &&
!std::disable_sized_sentinel_for<std::remove_cv_t<S>,
std::remove_cv_t<I>> && (1) (since C++20)
requires(const I& i, const S& s) {
{ s - i } -> std::same_as<std::iter_difference_t<I>>;
{ i - s } -> std::same_as<std::iter_difference_t<I>>;


};
template< class S, class I > (2) (since C++20)
inline constexpr bool disable_sized_sentinel_for = false;


1) The 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.
2) The 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.
A program may specialize disable_sized_sentinel_for for cv-unqualified non-array
object type S and I, as long as at least one of which is a program-defined type.
Such specializations are usable in constant expressions and have type const bool.

See also


ranges::sized_range specifies that a range knows its size in constant time
(C++20) (concept)
ranges::size returns an integer equal to the size of a range
(C++20) (customization point object)

2024.06.10 http://cppreference.com