[libcxx-commits] [libcxx] [libc++] P2944R3: Constrained comparisions - `optional` (PR #144249)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jun 16 04:34:33 PDT 2025
================
@@ -982,72 +983,133 @@ public:
template <class _Tp>
optional(_Tp) -> optional<_Tp>;
-// Comparisons between optionals
+// [optional.relops] Relational operators
+
+# if _LIBCPP_STD_VER >= 26
+template < class _Tp, class _Up>
+# else
template <
class _Tp,
class _Up,
enable_if_t<is_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, const optional<_Up>& __y) {
+# endif
+_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
+# if _LIBCPP_STD_VER >= 26
+ requires requires {
+ { *__x == *__y } -> __core_convertible_to<bool>;
----------------
philnik777 wrote:
Why would they be non-conforming?
https://github.com/llvm/llvm-project/pull/144249
More information about the libcxx-commits
mailing list