[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:11:33 PDT 2025


================
@@ -1851,7 +1871,14 @@ class expected<_Tp, _Err> : private __expected_void_base<_Err> {
   // [expected.void.eq], equality operators
   template <class _T2, class _E2>
     requires is_void_v<_T2>
-  _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y) {
+  _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _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 expected<_T2, _E2>& __y)
#  if _LIBCPP_STD_VER >= 26
    requires requires {
      { __x.error() == __y.error() } -> __core_convertible_to<bool>;
```

Let's remove the empty line here?

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


More information about the libcxx-commits mailing list