[libcxx-commits] [libcxx] [libc++] Extend __default_three_way_comparator to any types that only implements operator<=> (PR #157602)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 9 05:10:03 PDT 2025


================
@@ -38,6 +40,24 @@ struct __default_three_way_comparator<_Tp, _Tp, __enable_if_t<is_arithmetic<_Tp>
   }
 };
 
+#if _LIBCPP_STD_VER >= 20 && __has_builtin(__builtin_lt_synthesises_from_spaceship)
+template <class _LHS, class _RHS>
+struct __default_three_way_comparator<
+    _LHS,
+    _RHS,
+    __enable_if_t<(!is_arithmetic<_LHS>::value || !is_arithmetic<_RHS>::value) &&
----------------
ldionne wrote:

Nitpick but I'd use `!(is_arithmetic && is_arithmetic)` to be more symmetrical with the above.

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


More information about the libcxx-commits mailing list