std::ranges::SizedRange,std::ranges::disable_sized_range (3) - Linux Man Pages

std::ranges::SizedRange,std::ranges::disable_sized_range: std::ranges::SizedRange,std::ranges::disable_sized_range

NAME

std::ranges::SizedRange,std::ranges::disable_sized_range - std::ranges::SizedRange,std::ranges::disable_sized_range

Synopsis


Defined in header <ranges>
template< class T >
concept SizedRange = Range<T> &&
! disable_sized_range<std::remove_cvref_t<T>> && (1)
requires(T& t) {
ranges::size(t);
};
template<class> (2)
inline constexpr bool disable_sized_range = false;


1) The SizedRange concept specifies the requirements of a Range type that knows its size in constant time with the size function.
Formally, given an lvalue t of type std::remove_reference_t<T>, T models SizedRange only if


* ranges::size(t)


      * has non-amortized constant-time complexity,
      * does not modify t, and
      * is equal to ranges::distance(t), and


* if iterator_t<T> models ForwardIterator, ranges::size(t) is well-defined regardless of the evaluation of ranges::begin(t) (in other words, a single-pass sized range may support a call to size only before the first call to begin, but a forward range must support size at all times)


2) disable_sized_range exists to allows use of range types that satisfy but do not in fact model SizedRange.