std::ranges::reserve_hint
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
(customization point object)
(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>
Defined in header
<iterator>
inline namespace /* unspecified */ {
(since C++26) inline constexpr auto reserve_hint = /* unspecified */;
(customization point object)
Call signature
template< class T >
(since C++26)
requires /* see below */
Estimates the number of elements in t in constant time.
Given the subexpression of which t denotes the (possibly materialized) result object as E, and the type of E as T
:
- If ranges::size (E) is a valid expression, ranges::reserve_hint(E) is expression-equivalent to ranges::size (E).
- Otherwise, if auto(t.reserve_hint()) is a valid expression of integer-like type, ranges::reserve_hint(E) is expression-equivalent to auto(t.reserve_hint()).
- Otherwise, if all following conditions are satisfied, then ranges::reserve_hint(E) is expression-equivalent to auto(reserve_hint(t)):
-
T
is a class or enumeration type. - auto(reserve_hint(t)) is a valid expression of integer-like type, where the meaning of
reserve_hint
is established as if by performing argument-dependent lookup only.
-
- Otherwise, ranges::reserve_hint(E) is ill-formed.
Diagnosable ill-formed cases above result in substitution failure when ranges::reserve_hint(E) appears in the immediate context of a template instantiation.
Customization point objects
The name ranges::reserve_hint
denotes a customization point object, which is a const function object of a literal semiregular
class type. See CustomizationPointObject for details.
[edit] Notes
Whenever ranges::reserve_hint(e) is valid for an expression e, the return type is integer-like.
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_ranges_reserve_hint |
202502L |
(C++26) | ranges::reserve_hint |
[edit] Example
This section is incomplete
Reason: no example
Reason: no example