[range.approximately.sized] # 25 Ranges library [[ranges]](./#ranges) ## 25.4 Range requirements [[range.req]](range.req#range.approximately.sized) ### 25.4.3 Approximately sized ranges [range.approximately.sized] [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1427) The [approximately_sized_range](#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]") concept refines [range](range.range#concept:range "25.4.2 Ranges [range.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[.](#1.sentence-1) [🔗](#concept:approximately_sized_range) `template 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]") && requires(T& t) { ranges::reserve_hint(t); }; ` [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1440) Given an lvalue t of type remove_reference_t,T models [approximately_sized_range](#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]") only if - [(2.1)](#2.1) 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 - [(2.2)](#2.2) if iterator_t models [forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11 Concept forward_­iterator [iterator.concept.forward]"),ranges​::​reserve_hint(t) is well-defined regardless of the evaluation of ranges​::​begin(t)[.](#2.sentence-1) [*Note [1](#note-1)*: ranges​::​reserve_hint(t) is otherwise not required to be well-defined after evaluating ranges​::​begin(t)[.](#2.2.sentence-2) For example, it is possible for ranges​::​reserve_hint(t) to be well-defined for an [approximately_sized_range](#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]") whose iterator type does not model [forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11 Concept forward_­iterator [iterator.concept.forward]") only if evaluated before the first call to ranges​::​begin(t)[.](#2.2.sentence-3) — *end note*]