[libcxx-commits] [libcxx] [llvm] [libc++] Implement P3379R0 Constrain `std::expected` equality operators (PR #135759)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Tue Apr 29 00:13:26 PDT 2025


================
@@ -1860,7 +1887,14 @@ class expected<_Tp, _Err> : private __expected_void_base<_Err> {
   }
 
   template <class _E2>
-  _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __y) {
+  _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __y)
+#  if _LIBCPP_STD_VER >= 26
+
+    requires requires {
+      { __x.error() == __y.error() } -> __core_convertible_to<bool>;
+    }
----------------
Zingam wrote:

```suggestion
  _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __y)
#  if _LIBCPP_STD_VER >= 26
    requires requires {
      { __x.error() == __y.error() } -> __core_convertible_to<bool>;
    }
```
Here too... I think as this is a single statement is better to avoid empty lines. We don't put empty lines before `requires`.

https://github.com/llvm/llvm-project/pull/135759


More information about the libcxx-commits mailing list