]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Reorder template params of std::optional comparisons (LWG 2945)
authorJonathan Wakely <jwakely@redhat.com>
Tue, 23 Jul 2024 16:14:03 +0000 (17:14 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 25 Jul 2024 22:10:35 +0000 (23:10 +0100)
libstdc++-v3/ChangeLog:

* include/std/optional: Reorder parameters in comparison
operators as per LWG 2945.

libstdc++-v3/include/std/optional

index 2cc0221865e37dfaa9d6aa5e75f522833d052214..4694d594f98a091ff7d63901e7f1ab966b185711 100644 (file)
@@ -1601,10 +1601,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs && *__lhs == __rhs; }
 
   template<typename _Tp, typename _Up>
-    _REQUIRES_NOT_OPTIONAL(_Up)
+    _REQUIRES_NOT_OPTIONAL(_Tp)
     constexpr auto
-    operator==(const _Up& __lhs, const optional<_Tp>& __rhs)
-    -> __optional_eq_t<_Up, _Tp>
+    operator== [[nodiscard]] (const _Tp& __lhs, const optional<_Up>& __rhs)
+    -> __optional_eq_t<_Tp, _Up>
     { return __rhs && __lhs == *__rhs; }
 
   template<typename _Tp, typename _Up>
@@ -1615,10 +1615,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return !__lhs || *__lhs != __rhs; }
 
   template<typename _Tp, typename _Up>
-    _REQUIRES_NOT_OPTIONAL(_Up)
+    _REQUIRES_NOT_OPTIONAL(_Tp)
     constexpr auto
-    operator!= [[nodiscard]] (const _Up& __lhs, const optional<_Tp>& __rhs)
-    -> __optional_ne_t<_Up, _Tp>
+    operator!= [[nodiscard]] (const _Tp& __lhs, const optional<_Up>& __rhs)
+    -> __optional_ne_t<_Tp, _Up>
     { return !__rhs || __lhs != *__rhs; }
 
   template<typename _Tp, typename _Up>
@@ -1629,10 +1629,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return !__lhs || *__lhs < __rhs; }
 
   template<typename _Tp, typename _Up>
-    _REQUIRES_NOT_OPTIONAL(_Up)
+    _REQUIRES_NOT_OPTIONAL(_Tp)
     constexpr auto
-    operator< [[nodiscard]] (const _Up& __lhs, const optional<_Tp>& __rhs)
-    -> __optional_lt_t<_Up, _Tp>
+    operator< [[nodiscard]] (const _Tp& __lhs, const optional<_Up>& __rhs)
+    -> __optional_lt_t<_Tp, _Up>
     { return __rhs && __lhs < *__rhs; }
 
   template<typename _Tp, typename _Up>
@@ -1643,10 +1643,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs && *__lhs > __rhs; }
 
   template<typename _Tp, typename _Up>
-    _REQUIRES_NOT_OPTIONAL(_Up)
+    _REQUIRES_NOT_OPTIONAL(_Tp)
     constexpr auto
-    operator> [[nodiscard]] (const _Up& __lhs, const optional<_Tp>& __rhs)
-    -> __optional_gt_t<_Up, _Tp>
+    operator> [[nodiscard]] (const _Tp& __lhs, const optional<_Up>& __rhs)
+    -> __optional_gt_t<_Tp, _Up>
     { return !__rhs || __lhs > *__rhs; }
 
   template<typename _Tp, typename _Up>
@@ -1657,10 +1657,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return !__lhs || *__lhs <= __rhs; }
 
   template<typename _Tp, typename _Up>
-    _REQUIRES_NOT_OPTIONAL(_Up)
+    _REQUIRES_NOT_OPTIONAL(_Tp)
     constexpr auto
-    operator<= [[nodiscard]] (const _Up& __lhs, const optional<_Tp>& __rhs)
-    -> __optional_le_t<_Up, _Tp>
+    operator<= [[nodiscard]] (const _Tp& __lhs, const optional<_Up>& __rhs)
+    -> __optional_le_t<_Tp, _Up>
     { return __rhs && __lhs <= *__rhs; }
 
   template<typename _Tp, typename _Up>
@@ -1671,10 +1671,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return __lhs && *__lhs >= __rhs; }
 
   template<typename _Tp, typename _Up>
-    _REQUIRES_NOT_OPTIONAL(_Up)
+    _REQUIRES_NOT_OPTIONAL(_Tp)
     constexpr auto
-    operator>= [[nodiscard]] (const _Up& __lhs, const optional<_Tp>& __rhs)
-    -> __optional_ge_t<_Up, _Tp>
+    operator>= [[nodiscard]] (const _Tp& __lhs, const optional<_Up>& __rhs)
+    -> __optional_ge_t<_Tp, _Up>
     { return !__rhs || __lhs >= *__rhs; }
 
 #ifdef __cpp_lib_three_way_comparison