25 Ranges library [ranges]

25.3 Range access [range.access]

25.3.13 Approximately sized ranges [range.approximately.sized]

The approximately_sized_range concept refines range with the requirement that an approximation of the number of elements in the range can be determined in amortized constant time using ranges​::​reserve_hint.
template<class T> concept approximately_sized_range = range<T> && requires(T& t) { ranges::reserve_hint(t); };
Given an lvalue t of type remove_reference_t<T>, T models approximately_sized_range only if
  • ranges​::​reserve_hint(t) is amortized , does not modify t, and has a value that is not negative and is representable in range_difference_t<T>, and
  • if iterator_t<T> models forward_iterator, ranges​::​reserve_hint(t) is well-defined regardless of the evaluation of ranges​::​begin(t).
    [Note 1: 
    ranges​::​reserve_hint(t) is otherwise not required to be well-defined after evaluating ranges​::​
    begin(t)
    .
    For example, it is possible for ranges​::​reserve_hint(t) to be well-defined for an approximately_sized_range whose iterator type does not model forward_iterator only if evaluated before the first call to ranges​::​begin(t).
    — end note]