[libcxx-commits] [libcxx] [libc++] P2944R3: Constrained comparisions - `variant` and `tuple` (PR #141396)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jun 24 00:33:34 PDT 2025
================
@@ -1153,9 +1154,16 @@ struct __tuple_equal<0> {
};
template <class... _Tp, class... _Up>
+# if _LIBCPP_STD_VER >= 26
+ requires(requires(const _Tp& __t, const _Up& __u) {
+ { __t == __u } -> __boolean_testable;
+ } && ...) && (sizeof...(_Tp) == sizeof...(_Up))
+# endif
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
+# if _LIBCPP_STD_VER < 26
static_assert(sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
+# endif
----------------
philnik777 wrote:
I'm seeing this from the other side actually. It's guarded, so my first instinct is to wonder whether this restriction has been lifted in C++26. Just having the `static_assert` unconditionally tells the reader that it's always a requirement. Whether this is enforced through a constraint as well doesn't really bother me that much.
https://github.com/llvm/llvm-project/pull/141396
More information about the libcxx-commits
mailing list