std::ranges::approximately_sized_range
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Ranges library
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++26)(C++26)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
Defined in header
<ranges>
template< class T >
(since C++26)
concept approximately_sized_range = ranges::range <T> &&
requires(T& t) {
ranges::reserve_hint(t);
The approximately_sized_range
concept specifies the requirements of a range
type that can estimate its size in constant time with the reserve_hint
function.
[edit] Semantic requirements
Given an lvalue t of type std::remove_reference_t <T>, T
models approximately_sized_range
only if
- ranges::reserve_hint(t)
- has amortized constant-time complexity,
- does not alter the value of t in a manner observable to equality-preserving expressions, and
- has a value that is not negative and is representable in ranges::range_difference_t <T>, and
- if ranges::iterator_t <T> models
forward_iterator
, ranges::reserve_hint(t) is well-defined regardless of the evaluation of ranges::begin (t) (in other words, a single-pass approximately sized range may support a call toreserve_hint
only before the first call tobegin
, but a forward range must support size at all times).
[edit] Notes
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_ranges_reserve_hint |
202502L |
(C++26) | ranges::approximately_sized_range |
[edit] Example
This section is incomplete
Reason: no example
Reason: no example