]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Use _M_reverse to reverse partial_ordering using operator<=>
authorTomasz Kamiński <tkaminsk@redhat.com>
Wed, 27 Aug 2025 14:43:16 +0000 (16:43 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Wed, 27 Aug 2025 15:09:07 +0000 (17:09 +0200)
The patch r16-3414-gfcb3009a32dc33 changed the representation of unordered to
optimize reversing of order, but it did not update implementation of reversing
operator<=>(0, partial_order).

libstdc++-v3/ChangeLog:

* libsupc++/compare
(operator<=>(__cmp_cat::__unspec, partial_ordering)):
Implement using _M_reverse.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
libstdc++-v3/libsupc++/compare

index 2624fa9144fbb78de82a7d32ee926ca94efa0e85..ef0f037696468604dbae487d1bad76d447a864eb 100644 (file)
@@ -155,12 +155,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
     [[nodiscard]]
     friend constexpr partial_ordering
     operator<=>(__cmp_cat::__unspec, partial_ordering __v) noexcept
-    {
-      if (__v._M_value & 1)
-       return partial_ordering(__cmp_cat::_Ord(-__v._M_value));
-      else
-       return __v;
-    }
+    { return partial_ordering(__cmp_cat::_Ncmp(__v._M_reverse())); }
   };
 
   // valid values' definitions