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

Dan Shan via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 31 06:20:44 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,
----------------
HumanThe2nd wrote:

> Please, make sure to clang-format your changes before submitting but be careful not to format unrelated stuff. If needed unrelated changes are delegated to separate PRs.

If I'm not mistaken, the suggested change would exceed this file's 120-character column limit, which failed the clang-format check on my first push. The current formatting is to accommodate the failed test. Let me know if there's a better alternative, thanks.

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


More information about the libcxx-commits mailing list