[libcxx-commits] [libcxx] [libc++] Remove SFINAE checks in tuple which are always true (PR #212765)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 30 02:17:42 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

<details>
<summary>Changes</summary>

We have a specialization for `tuple` with no arguments, so checking
`sizeof...(_Tp) >= 1` in the primary template will never be false.


---
Full diff: https://github.com/llvm/llvm-project/pull/212765.diff


1 Files Affected:

- (modified) libcxx/include/tuple (+5-7) 


``````````diff
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index e1d723ecaf012..158729969288d 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -591,15 +591,14 @@ public:
       : __base_(allocator_arg_t(), __a, __value_init{}) {}
 
   // tuple(const T&...) constructors (including allocator_arg_t variants)
-  template <template <class...> class _And = _And,
-            __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0>
+  template <template <class...> class _And = _And, __enable_if_t<_And<is_copy_constructible<_Tp>...>::value, int> = 0>
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_And<is_convertible<const _Tp&, _Tp>...>::value)
       tuple(const _Tp&... __t) noexcept(_And<is_nothrow_copy_constructible<_Tp>...>::value)
       : __base_(__forward_args{}, __t...) {}
 
   template <class _Alloc,
-            template <class...> class _And = _And,
-            __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0>
+            template <class...> class _And                                 = _And,
+            __enable_if_t<_And<is_copy_constructible<_Tp>...>::value, int> = 0>
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(!_And<is_convertible<const _Tp&, _Tp>...>::value)
       tuple(allocator_arg_t, const _Alloc& __a, const _Tp&... __t)
       : __base_(allocator_arg_t(), __a, __forward_args{}, __t...) {}
@@ -612,9 +611,8 @@ public:
 
   template <class... _Up>
   struct _EnableUTypesCtor
-      : _And< _BoolConstant<sizeof...(_Tp) >= 1>,
-              _Not<_IsThisTuple<_Up...> >, // extension to allow mis-behaved user constructors
-              is_constructible<_Tp, _Up>... > {};
+      : _And<_Not<_IsThisTuple<_Up...> >, // extension to allow mis-behaved user constructors
+             is_constructible<_Tp, _Up>... > {};
 
   template <class... _Up,
             __enable_if_t< _And< _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, _EnableUTypesCtor<_Up...> >::value,

``````````

</details>


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


More information about the libcxx-commits mailing list