Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::weak_order

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

         inlineconstexpr/* unspecified */ weak_order=/* unspecified */;

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

          requires/* see below */

      constexprstd::weak_ordering weak_order(T&& t, U&& u)noexcept(/* see below */);

      Compares two values using 3-way comparison and produces a result of typestd::weak_ordering.

      Lett andu be expressions andT andU denotedecltype((t)) anddecltype((u)) respectively,std::weak_order(t, u) isexpression-equivalent to:

      Contents

      Customization point objects

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

      [edit]Strict weak order of IEEE floating-point types

      Letx andy be values of same IEEE floating-point type, andweak_order_less(x, y) be the boolean result indicating ifx precedesy in the strict weak order defined by the C++ standard.

      • If neitherx nory is NaN, thenweak_order_less(x, y)==true if and only ifx< y, i.e. all representations of equal floating-point value are equivalent;
      • Ifx is negative NaN andy is not negative NaN, thenweak_order_less(x, y)==true;
      • Ifx is not positive NaN andy is positive NaN, thenweak_order_less(x, y)==true;
      • If bothx andy are NaNs with the same sign, then(weak_order_less(x, y)|| weak_order_less(y, x))==false, i.e. all NaNs with the same sign are equivalent.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      the result type of 3-way comparison that supports all 6 operators and is not substitutable
      (class)[edit]
      performs 3-way comparison and produces a result of typestd::strong_ordering
      (customization point object)[edit]
      performs 3-way comparison and produces a result of typestd::partial_ordering
      (customization point object)[edit]
      performs 3-way comparison and produces a result of typestd::weak_ordering, even ifoperator<=> is unavailable
      (customization point object)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility/compare/weak_order&oldid=150892"

      [8]ページ先頭

      ©2009-2025 Movatter.jp