[libcxx-commits] [libcxx] [libc++] Implement comparison operators for `tuple` added in C++23 (PR #148799)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jul 19 00:03:05 PDT 2025


================
@@ -288,6 +296,66 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #  ifndef _LIBCPP_CXX03_LANG
 
+template <size_t _Ip, class _Tp, class _Up>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool __tuple_compare_equal(const _Tp& __x, const _Up& __y) {
+  if constexpr (_Ip == 0)
+    return true;
+  else
+    return std::__tuple_compare_equal<_Ip - 1>(__x, __y) && std::get<_Ip - 1>(__x) == std::get<_Ip - 1>(__y);
+}
+
+#    if _LIBCPP_STD_VER >= 26
+template <class _Tp, class _Up, class _IndexSeq>
+inline constexpr bool __can_tuple_compare_equal_impl = false;
----------------
frederick-vs-ja wrote:

Thanks! I've applied suggestions for produce code.

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


More information about the libcxx-commits mailing list