[libcxx-commits] [libcxx] [libc++] Implement LWG4072: std::optional comparisons: constrain harder (PR #209968)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 28 08:25:00 PDT 2026


================
@@ -1543,7 +1543,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const optional<_Tp>&
 template <
     class _Tp,
     class _Up,
-    enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>,
+    enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool> &&
+                    !__is_std_optional<_Up>::value,
----------------
Zingam wrote:


> (No change requested) Also I wonder why don't we have an alias for `__is_std_optional<>::value` such as `__is_std_optional_v` to improve the readability.


I just merged: https://github.com/llvm/llvm-project/pull/212443
with the proposed change. Please rebase your PR and update with the new name.

e.g.

```suggestion
    enable_if_t<!__is_std_optional_v<_Up> && __is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()),
```


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


More information about the libcxx-commits mailing list