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

From cppreference.com
< cpp‎ | ranges

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

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.
Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/SizedRange&oldid=109706"