std::ranges::reserve_hint - cppreference.com (original) (raw)

| Defined in header | | | | ---------------------------------------------------------------------------------------------------- | | ------------------------------------------ | | Defined in header | | | | inline namespace /* unspecified */ { inline constexpr auto reserve_hint = /* unspecified */; } | | (since C++26) (customization point object) | | Call signature | | | | template< class T > requires /* see below */ constexpr auto reserve_hint( T&& t ); | | (since C++26) |

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:

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

[edit] See also