Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ranges::reserve_hint

      From cppreference.com
      <cpp‎ |ranges
       
       
      Ranges library
      Range adaptors
       
      Defined in header<ranges>
      Defined in header<iterator>
      inlinenamespace/* unspecified */{

         inlineconstexprauto reserve_hint=/* unspecified */;

      }
      (since C++26)
      (customization point object)
      Call signature
      template<class T>

          requires/* see below */

      constexprauto reserve_hint( T&& t);
      (since C++26)

      Estimates the number of elements int in constant time.

      Given thesubexpression of whicht denotes the (possiblymaterialized) result object asE, and the type ofE asT:

      • Ifranges::size(E) is a valid expression,ranges::reserve_hint(E) isexpression-equivalent toranges::size(E).
      • Otherwise, ifauto(t.reserve_hint()) is a valid expression ofinteger-like type,ranges::reserve_hint(E) is expression-equivalent toauto(t.reserve_hint()).
      • Otherwise, if all following conditions are satisfied, thenranges::reserve_hint(E) is expression-equivalent toauto(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 ofreserve_hint is established as if by performingargument-dependent lookup only.
      • Otherwise,ranges::reserve_hint(E) is ill-formed.

      Diagnosable ill-formed cases above result insubstitution failure whenranges::reserve_hint(E) appears in the immediate context of a template instantiation.

      Contents

      Customization point objects

      The nameranges::reserve_hint denotes acustomization point object, which is a constfunction object of aliteralsemiregular class type. SeeCustomizationPointObject for details.

      [edit]Notes

      Wheneverranges::reserve_hint(e) is valid for an expressione, the return type isinteger-like.

      Feature-test macroValueStdFeature
      __cpp_lib_ranges_reserve_hint202502L(C++26)ranges::reserve_hint

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      returns an integer equal to the size of a range
      (customization point object)[edit]
      returns a signed integer equal to the size of a range
      (customization point object)[edit]
      specifies that a range can estimate its size in constant time
      (concept)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/reserve_hint&oldid=182367"

      [8]ページ先頭

      ©2009-2025 Movatter.jp