2.5 KiB
[range.approximately.sized]
25 Ranges library [ranges]
25.4 Range requirements [range.req]
25.4.3 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](#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]") = [range](range.range#concept:range "25.4.2 Ranges [range.range]")<T> && requires(T& t) { ranges::reserve_hint(t); };
Given an lvalue t of type remove_reference_t,T models approximately_sized_range only if
ranges::reserve_hint(t) is amortized O(1), does not modify t, and has a value that is not negative and is representable in range_difference_t, and
if iterator_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]