]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Simplify constraints on <=> for std::reference_wrapper master trunk
authorJonathan Wakely <jwakely@redhat.com>
Fri, 19 Apr 2024 16:42:04 +0000 (17:42 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 19 Apr 2024 20:06:29 +0000 (21:06 +0100)
Instead of constraining these overloads in terms of synth-three-way we
can just check that the value_type is less-than-comparable, which is
what synth-three-way's constraints check.

The reason that I implemented these with constraints has now been filed
as LWG 4071, so add a comment about that too.

libstdc++-v3/ChangeLog:

* include/bits/refwrap.h (operator<=>): Simplify constraints.

libstdc++-v3/include/bits/refwrap.h

index fd1cc2b63e67a88401b98d7edc95b875a8f53eaa..71ec2b297b7c1c4d7b5691c2790550553b68ec0a 100644 (file)
@@ -384,23 +384,29 @@ _GLIBCXX_MEM_FN_TRAITS(&& noexcept, false_type, true_type)
        && requires { { __x.get() == __y.get() } -> convertible_to<bool>; }
       { return __x.get() == __y.get(); }
 
+      // _GLIBCXX_RESOLVE_LIB_DEFECTS
+      // 4071. reference_wrapper comparisons are not SFINAE-friendly
+
       [[nodiscard]]
       friend constexpr auto
-      operator<=>(reference_wrapper __x, reference_wrapper<_Tp> __y)
-      requires requires { __detail::__synth3way(__x.get(), __y.get()); }
+      operator<=>(reference_wrapper __x, reference_wrapper __y)
+      requires requires (const _Tp __t) {
+       { __t < __t } -> __detail::__boolean_testable;
+      }
       { return __detail::__synth3way(__x.get(), __y.get()); }
 
       [[nodiscard]]
       friend constexpr auto
       operator<=>(reference_wrapper __x, const _Tp& __y)
-      requires requires { __detail::__synth3way(__x.get(), __y); }
+      requires requires { { __y < __y } -> __detail::__boolean_testable; }
       { return __detail::__synth3way(__x.get(), __y); }
 
       [[nodiscard]]
       friend constexpr auto
       operator<=>(reference_wrapper __x, reference_wrapper<const _Tp> __y)
-      requires (!is_const_v<_Tp>)
-       && requires { __detail::__synth3way(__x.get(), __y.get()); }
+      requires (!is_const_v<_Tp>) && requires (const _Tp __t) {
+       { __t < __t } -> __detail::__boolean_testable;
+      }
       { return __detail::__synth3way(__x.get(), __y.get()); }
 #endif
     };