Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::compare_strong_order_fallback

      From cppreference.com
      <cpp‎ |utility
       
       
      Utilities library
       
      Defined in header<compare>
      inlinenamespace/* unspecified */{

         inlineconstexpr/* unspecified */
              compare_strong_order_fallback=/* unspecified */;

      }
      (since C++20)
      Call signature
      template<class T,class U>

          requires/* see below */
      constexprstd::strong_ordering

          compare_strong_order_fallback( T&& t, U&& u)noexcept(/* see below */);
      (since C++20)

      Performs three-way comparison onsubexpressionst andu and produces a result of typestd::strong_ordering, even if the operator<=> is unavailable.

      Ifstd::decay_t<T> andstd::decay_t<U> are the same type,std::compare_strong_order_fallback(t, u) isexpression-equivalent to:

      • std::strong_order(t, u), if it is a well-formed expression;
      • otherwise,t== u? std::strong_ordering::equal:
        t< u  ? std::strong_ordering::less:
                 std::strong_ordering::greater
      if the expressionst== u andt< u are both well-formed and each ofdecltype(t== u) anddecltype(t< u) modelsboolean-testable, except thatt andu are evaluated only once.

      In all other cases,std::compare_strong_order_fallback(t, u) is ill-formed, which can result insubstitution failure when it appears in the immediate context of a template instantiation.

      Contents

      Customization point objects

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

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 2114
      (P2167R3)
      C++20the fallback mechanism only required
      return types to be convertible tobool
      constraints strengthened

      [edit]See also

      performs 3-way comparison and produces a result of typestd::strong_ordering
      (customization point object)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility/compare/compare_strong_order_fallback&oldid=151372"

      [8]ページ先頭

      ©2009-2025 Movatter.jp