[libcxx-commits] [libcxx] 4da76ea - [libc++][NFC] Refactor enable_ifs in defaulted arguments to defaulted template arguments

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 18 13:08:26 PDT 2023


Author: Nikolas Klauser
Date: 2023-08-18T13:08:18-07:00
New Revision: 4da76ea70ad3d225d495703efca9b2f56bdefbf6

URL: https://github.com/llvm/llvm-project/commit/4da76ea70ad3d225d495703efca9b2f56bdefbf6
DIFF: https://github.com/llvm/llvm-project/commit/4da76ea70ad3d225d495703efca9b2f56bdefbf6.diff

LOG: [libc++][NFC] Refactor enable_ifs in defaulted arguments to defaulted template arguments

This brings most of the enable_ifs in libc++ to the same style. It also has the nice side-effect of reducing the size of names of these symbols, since the arguments don't get mangled anymore.

Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D157748

Added: 
    

Modified: 
    libcxx/include/__chrono/duration.h
    libcxx/include/__chrono/time_point.h
    libcxx/include/__iterator/wrap_iter.h
    libcxx/include/__memory/shared_ptr.h
    libcxx/include/__memory/unique_ptr.h
    libcxx/include/__random/discard_block_engine.h
    libcxx/include/__random/independent_bits_engine.h
    libcxx/include/__random/linear_congruential_engine.h
    libcxx/include/__random/mersenne_twister_engine.h
    libcxx/include/__random/shuffle_order_engine.h
    libcxx/include/__random/subtract_with_carry_engine.h
    libcxx/include/__system_error/error_code.h
    libcxx/include/__system_error/error_condition.h
    libcxx/include/deque
    libcxx/include/vector

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__chrono/duration.h b/libcxx/include/__chrono/duration.h
index 4c84278426887b..e4e5f03b48bf32 100644
--- a/libcxx/include/__chrono/duration.h
+++ b/libcxx/include/__chrono/duration.h
@@ -234,28 +234,20 @@ class _LIBCPP_TEMPLATE_VIS duration
         _LIBCPP_HIDE_FROM_ABI duration() {}
 #endif
 
-    template <class _Rep2>
+    template <class _Rep2, __enable_if_t<is_convertible<const _Rep2&, rep>::value &&
+                                         (treat_as_floating_point<rep>::value ||
+                                          !treat_as_floating_point<_Rep2>::value), int> = 0>
         _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-        explicit duration(const _Rep2& __r,
-            typename enable_if
-            <
-               is_convertible<const _Rep2&, rep>::value &&
-               (treat_as_floating_point<rep>::value ||
-               !treat_as_floating_point<_Rep2>::value)
-            >::type* = nullptr)
+        explicit duration(const _Rep2& __r)
                 : __rep_(__r) {}
 
     // conversions
-    template <class _Rep2, class _Period2>
+    template <class _Rep2, class _Period2, __enable_if_t<__no_overflow<_Period2, period>::value && (
+                                                            treat_as_floating_point<rep>::value ||
+                                                            (__no_overflow<_Period2, period>::type::den == 1 &&
+                                                             !treat_as_floating_point<_Rep2>::value)), int> = 0>
         _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-        duration(const duration<_Rep2, _Period2>& __d,
-            typename enable_if
-            <
-                __no_overflow<_Period2, period>::value && (
-                treat_as_floating_point<rep>::value ||
-                (__no_overflow<_Period2, period>::type::den == 1 &&
-                 !treat_as_floating_point<_Rep2>::value))
-            >::type* = nullptr)
+        duration(const duration<_Rep2, _Period2>& __d)
                 : __rep_(chrono::duration_cast<duration>(__d).count()) {}
 
     // observer

diff  --git a/libcxx/include/__chrono/time_point.h b/libcxx/include/__chrono/time_point.h
index d804d9d62bba6a..741165bd3f43bb 100644
--- a/libcxx/include/__chrono/time_point.h
+++ b/libcxx/include/__chrono/time_point.h
@@ -49,13 +49,9 @@ class _LIBCPP_TEMPLATE_VIS time_point
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit time_point(const duration& __d) : __d_(__d) {}
 
     // conversions
-    template <class _Duration2>
+    template <class _Duration2, __enable_if_t<is_convertible<_Duration2, duration>::value, int> = 0>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
-    time_point(const time_point<clock, _Duration2>& __t,
-        typename enable_if
-        <
-            is_convertible<_Duration2, duration>::value
-        >::type* = nullptr)
+    time_point(const time_point<clock, _Duration2>& __t)
             : __d_(__t.time_since_epoch()) {}
 
     // observer

diff  --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h
index 774276baa81c7c..8cab2179cfef09 100644
--- a/libcxx/include/__iterator/wrap_iter.h
+++ b/libcxx/include/__iterator/wrap_iter.h
@@ -45,9 +45,8 @@ class __wrap_iter
                 : __i_()
     {
     }
-    template <class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
-        __wrap_iter(const __wrap_iter<_Up>& __u,
-            typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT
+    template <class _Up, __enable_if_t<is_convertible<_Up, iterator_type>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter(const __wrap_iter<_Up>& __u) _NOEXCEPT
             : __i_(__u.base())
     {
     }

diff  --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index e032e3752ebb14..abdf9aa274d4e4 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -1624,20 +1624,22 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr
 public:
     _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT;
-    template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(shared_ptr<_Yp> const& __r,
-                   typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0)
-                        _NOEXCEPT;
+
+    template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
+    _LIBCPP_INLINE_VISIBILITY weak_ptr(shared_ptr<_Yp> const& __r) _NOEXCEPT;
+
     _LIBCPP_INLINE_VISIBILITY
     weak_ptr(weak_ptr const& __r) _NOEXCEPT;
-    template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp> const& __r,
-                   typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0)
-                         _NOEXCEPT;
+
+    template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
+    _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp> const& __r) _NOEXCEPT;
 
     _LIBCPP_INLINE_VISIBILITY
     weak_ptr(weak_ptr&& __r) _NOEXCEPT;
-    template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r,
-                   typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0)
-                         _NOEXCEPT;
+
+    template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
+    _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r) _NOEXCEPT;
+
     _LIBCPP_HIDE_FROM_ABI ~weak_ptr();
 
     _LIBCPP_INLINE_VISIBILITY
@@ -1706,10 +1708,9 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT
 }
 
 template<class _Tp>
-template<class _Yp>
+template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> >
 inline
-weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r,
-                        typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type)
+weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r)
                          _NOEXCEPT
     : __ptr_(__r.__ptr_),
       __cntrl_(__r.__cntrl_)
@@ -1719,10 +1720,9 @@ weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r,
 }
 
 template<class _Tp>
-template<class _Yp>
+template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> >
 inline
-weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r,
-                        typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type)
+weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r)
          _NOEXCEPT
     : __ptr_(__r.__ptr_),
       __cntrl_(__r.__cntrl_)
@@ -1742,10 +1742,9 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT
 }
 
 template<class _Tp>
-template<class _Yp>
+template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> >
 inline
-weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r,
-                        typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type)
+weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r)
          _NOEXCEPT
     : __ptr_(__r.__ptr_),
       __cntrl_(__r.__cntrl_)

diff  --git a/libcxx/include/__memory/unique_ptr.h b/libcxx/include/__memory/unique_ptr.h
index 295e0575ad46ad..6ce50f71482eb1 100644
--- a/libcxx/include/__memory/unique_ptr.h
+++ b/libcxx/include/__memory/unique_ptr.h
@@ -58,9 +58,9 @@ struct _LIBCPP_TEMPLATE_VIS default_delete {
 #else
   _LIBCPP_INLINE_VISIBILITY default_delete() {}
 #endif
-  template <class _Up>
+  template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value, int> = 0>
   _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(
-      const default_delete<_Up>&, typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {}
+      const default_delete<_Up>&) _NOEXCEPT {}
 
   _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Tp* __ptr) const _NOEXCEPT {
     static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
@@ -221,12 +221,10 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
       : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {}
 
 #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
-  template <class _Up>
+  template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value &&
+                                     is_same<_Dp, default_delete<_Tp> >::value, int> = 0>
   _LIBCPP_INLINE_VISIBILITY
-  unique_ptr(auto_ptr<_Up>&& __p,
-             typename enable_if<is_convertible<_Up*, _Tp*>::value &&
-                                    is_same<_Dp, default_delete<_Tp> >::value,
-                                __nat>::type = __nat()) _NOEXCEPT
+  unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT
       : __ptr_(__p.release(), __value_init_tag()) {}
 #endif
 

diff  --git a/libcxx/include/__random/discard_block_engine.h b/libcxx/include/__random/discard_block_engine.h
index 5995bd3d352fb3..734cb257c3178e 100644
--- a/libcxx/include/__random/discard_block_engine.h
+++ b/libcxx/include/__random/discard_block_engine.h
@@ -72,11 +72,10 @@ class _LIBCPP_TEMPLATE_VIS discard_block_engine
 #endif // _LIBCPP_CXX03_LANG
     _LIBCPP_INLINE_VISIBILITY
     explicit discard_block_engine(result_type __sd) : __e_(__sd), __n_(0) {}
-    template<class _Sseq>
+    template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, discard_block_engine>::value &&
+                                        !is_convertible<_Sseq, _Engine>::value, int> = 0>
         _LIBCPP_INLINE_VISIBILITY
-        explicit discard_block_engine(_Sseq& __q,
-        typename enable_if<__is_seed_sequence<_Sseq, discard_block_engine>::value &&
-                           !is_convertible<_Sseq, _Engine>::value>::type* = 0)
+        explicit discard_block_engine(_Sseq& __q)
         : __e_(__q), __n_(0) {}
     _LIBCPP_INLINE_VISIBILITY
     void seed() {__e_.seed(); __n_ = 0;}

diff  --git a/libcxx/include/__random/independent_bits_engine.h b/libcxx/include/__random/independent_bits_engine.h
index ce527d9de42b82..0164ce08fb5d4b 100644
--- a/libcxx/include/__random/independent_bits_engine.h
+++ b/libcxx/include/__random/independent_bits_engine.h
@@ -104,11 +104,10 @@ class _LIBCPP_TEMPLATE_VIS independent_bits_engine
 #endif // _LIBCPP_CXX03_LANG
     _LIBCPP_INLINE_VISIBILITY
     explicit independent_bits_engine(result_type __sd) : __e_(__sd) {}
-    template<class _Sseq>
+    template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, independent_bits_engine>::value &&
+                                        !is_convertible<_Sseq, _Engine>::value, int> = 0>
         _LIBCPP_INLINE_VISIBILITY
-        explicit independent_bits_engine(_Sseq& __q,
-        typename enable_if<__is_seed_sequence<_Sseq, independent_bits_engine>::value &&
-                           !is_convertible<_Sseq, _Engine>::value>::type* = 0)
+        explicit independent_bits_engine(_Sseq& __q)
          : __e_(__q) {}
     _LIBCPP_INLINE_VISIBILITY
     void seed() {__e_.seed();}

diff  --git a/libcxx/include/__random/linear_congruential_engine.h b/libcxx/include/__random/linear_congruential_engine.h
index 1cf138c00e2a6e..3a2a3444062f64 100644
--- a/libcxx/include/__random/linear_congruential_engine.h
+++ b/libcxx/include/__random/linear_congruential_engine.h
@@ -246,10 +246,9 @@ class _LIBCPP_TEMPLATE_VIS linear_congruential_engine
       seed(__s);
     }
 #endif
-    template<class _Sseq>
+    template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, linear_congruential_engine>::value, int> = 0>
         _LIBCPP_INLINE_VISIBILITY
-        explicit linear_congruential_engine(_Sseq& __q,
-        typename enable_if<__is_seed_sequence<_Sseq, linear_congruential_engine>::value>::type* = 0)
+        explicit linear_congruential_engine(_Sseq& __q)
         {seed(__q);}
     _LIBCPP_INLINE_VISIBILITY
     void seed(result_type __s = default_seed)

diff  --git a/libcxx/include/__random/mersenne_twister_engine.h b/libcxx/include/__random/mersenne_twister_engine.h
index 081b9617828454..9a06cfdb0080e2 100644
--- a/libcxx/include/__random/mersenne_twister_engine.h
+++ b/libcxx/include/__random/mersenne_twister_engine.h
@@ -135,10 +135,9 @@ class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine
       seed(__sd);
     }
 #endif
-    template<class _Sseq>
+    template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value, int> = 0>
         _LIBCPP_INLINE_VISIBILITY
-        explicit mersenne_twister_engine(_Sseq& __q,
-        typename enable_if<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value>::type* = 0)
+        explicit mersenne_twister_engine(_Sseq& __q)
         {seed(__q);}
     _LIBCPP_HIDE_FROM_ABI void seed(result_type __sd = default_seed);
     template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value, int> = 0>

diff  --git a/libcxx/include/__random/shuffle_order_engine.h b/libcxx/include/__random/shuffle_order_engine.h
index ad3422519b9f6b..2c7c22db1feea2 100644
--- a/libcxx/include/__random/shuffle_order_engine.h
+++ b/libcxx/include/__random/shuffle_order_engine.h
@@ -98,11 +98,10 @@ class _LIBCPP_TEMPLATE_VIS shuffle_order_engine
 #endif // _LIBCPP_CXX03_LANG
     _LIBCPP_INLINE_VISIBILITY
     explicit shuffle_order_engine(result_type __sd) : __e_(__sd) {__init();}
-    template<class _Sseq>
+    template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, shuffle_order_engine>::value &&
+                                        !is_convertible<_Sseq, _Engine>::value, int> = 0>
         _LIBCPP_INLINE_VISIBILITY
-        explicit shuffle_order_engine(_Sseq& __q,
-        typename enable_if<__is_seed_sequence<_Sseq, shuffle_order_engine>::value &&
-                           !is_convertible<_Sseq, _Engine>::value>::type* = 0)
+        explicit shuffle_order_engine(_Sseq& __q)
          : __e_(__q) {__init();}
     _LIBCPP_INLINE_VISIBILITY
     void seed() {__e_.seed(); __init();}

diff  --git a/libcxx/include/__random/subtract_with_carry_engine.h b/libcxx/include/__random/subtract_with_carry_engine.h
index afff83e2007bae..2f0b1c7a65c239 100644
--- a/libcxx/include/__random/subtract_with_carry_engine.h
+++ b/libcxx/include/__random/subtract_with_carry_engine.h
@@ -101,10 +101,9 @@ class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine
       seed(__sd);
     }
 #endif
-    template<class _Sseq>
+    template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, subtract_with_carry_engine>::value, int> = 0>
         _LIBCPP_INLINE_VISIBILITY
-        explicit subtract_with_carry_engine(_Sseq& __q,
-        typename enable_if<__is_seed_sequence<_Sseq, subtract_with_carry_engine>::value>::type* = 0)
+        explicit subtract_with_carry_engine(_Sseq& __q)
         {seed(__q);}
     _LIBCPP_INLINE_VISIBILITY
     void seed(result_type __sd = default_seed)

diff  --git a/libcxx/include/__system_error/error_code.h b/libcxx/include/__system_error/error_code.h
index 6188888aa778d7..475f2bb96a56d9 100644
--- a/libcxx/include/__system_error/error_code.h
+++ b/libcxx/include/__system_error/error_code.h
@@ -49,9 +49,8 @@ class _LIBCPP_EXPORTED_FROM_ABI error_code {
 
   _LIBCPP_HIDE_FROM_ABI error_code(int __val, const error_category& __cat) _NOEXCEPT : __val_(__val), __cat_(&__cat) {}
 
-  template <class _Ep>
-  _LIBCPP_HIDE_FROM_ABI
-  error_code(_Ep __e, typename enable_if<is_error_code_enum<_Ep>::value>::type* = nullptr) _NOEXCEPT {
+  template <class _Ep, __enable_if_t<is_error_code_enum<_Ep>::value, int> = 0>
+  _LIBCPP_HIDE_FROM_ABI error_code(_Ep __e) _NOEXCEPT {
     using __adl_only::make_error_code;
     *this = make_error_code(__e);
   }

diff  --git a/libcxx/include/__system_error/error_condition.h b/libcxx/include/__system_error/error_condition.h
index 278598378bf589..42898c1f0e9013 100644
--- a/libcxx/include/__system_error/error_condition.h
+++ b/libcxx/include/__system_error/error_condition.h
@@ -58,9 +58,8 @@ class _LIBCPP_EXPORTED_FROM_ABI error_condition {
       : __val_(__val),
         __cat_(&__cat) {}
 
-  template <class _Ep>
-  _LIBCPP_HIDE_FROM_ABI
-  error_condition(_Ep __e, typename enable_if<is_error_condition_enum<_Ep>::value>::type* = nullptr) _NOEXCEPT {
+  template <class _Ep, __enable_if_t<is_error_condition_enum<_Ep>::value, int> = 0>
+  _LIBCPP_HIDE_FROM_ABI error_condition(_Ep __e) _NOEXCEPT {
     using __adl_only::make_error_condition;
     *this = make_error_condition(__e);
   }

diff  --git a/libcxx/include/deque b/libcxx/include/deque
index 8ca59438db444a..6b6d8e2bdda668 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -284,10 +284,9 @@ public:
 #endif
      {}
 
-    template <class _Pp, class _Rp, class _MP>
+    template <class _Pp, class _Rp, class _MP, __enable_if_t<is_convertible<_Pp, pointer>::value, int> = 0>
     _LIBCPP_HIDE_FROM_ABI
-    __deque_iterator(const __deque_iterator<value_type, _Pp, _Rp, _MP, 
diff erence_type, _BS>& __it,
-                typename enable_if<is_convertible<_Pp, pointer>::value>::type* = 0) _NOEXCEPT
+    __deque_iterator(const __deque_iterator<value_type, _Pp, _Rp, _MP, 
diff erence_type, _BS>& __it) _NOEXCEPT
         : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {}
 
     _LIBCPP_HIDE_FROM_ABI reference operator*() const {return *__ptr_;}
@@ -614,12 +613,10 @@ public:
             __append(__n, __v);
     }
 
-    template <class _InputIter>
-    _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l,
-              typename enable_if<__has_input_iterator_category<_InputIter>::value>::type* = 0);
-    template <class _InputIter>
-    _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
-              typename enable_if<__has_input_iterator_category<_InputIter>::value>::type* = 0);
+    template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l);
+    template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l, const allocator_type& __a);
 
 #if _LIBCPP_STD_VER >= 23
   template <_ContainerCompatibleRange<_Tp> _Range>
@@ -662,13 +659,11 @@ public:
     void assign(initializer_list<value_type> __il) {assign(__il.begin(), __il.end());}
 #endif // _LIBCPP_CXX03_LANG
 
-    template <class _InputIter>
-    _LIBCPP_HIDE_FROM_ABI void assign(_InputIter __f, _InputIter __l,
-                    typename enable_if<__has_input_iterator_category<_InputIter>::value &&
-                                      !__has_random_access_iterator_category<_InputIter>::value>::type* = 0);
-    template <class _RAIter>
-    _LIBCPP_HIDE_FROM_ABI void assign(_RAIter __f, _RAIter __l,
-                    typename enable_if<__has_random_access_iterator_category<_RAIter>::value>::type* = 0);
+    template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value &&
+                                              !__has_random_access_iterator_category<_InputIter>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI void assign(_InputIter __f, _InputIter __l);
+    template <class _RAIter, __enable_if_t<__has_random_access_iterator_category<_RAIter>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI void assign(_RAIter __f, _RAIter __l);
 
 #if _LIBCPP_STD_VER >= 23
     template <_ContainerCompatibleRange<_Tp> _Range>
@@ -820,15 +815,12 @@ public:
 #endif // _LIBCPP_CXX03_LANG
     _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v);
     _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __v);
-    template <class _InputIter>
-    _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InputIter __f, _InputIter __l,
-                         typename enable_if<__has_exactly_input_iterator_category<_InputIter>::value>::type* = 0);
-    template <class _ForwardIterator>
-    _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
-                        typename enable_if<__has_exactly_forward_iterator_category<_ForwardIterator>::value>::type* = 0);
-    template <class _BiIter>
-    _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _BiIter __f, _BiIter __l,
-                         typename enable_if<__has_bidirectional_iterator_category<_BiIter>::value>::type* = 0);
+    template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InputIter __f, _InputIter __l);
+    template <class _ForwardIterator, __enable_if_t<__has_exactly_forward_iterator_category<_ForwardIterator>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l);
+    template <class _BiIter, __enable_if_t<__has_bidirectional_iterator_category<_BiIter>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _BiIter __f, _BiIter __l);
 
 #if _LIBCPP_STD_VER >= 23
     template <_ContainerCompatibleRange<_Tp> _Range>
@@ -1262,12 +1254,10 @@ public:
     _LIBCPP_HIDE_FROM_ABI
     iterator __insert_bidirectional(const_iterator __p, _BiIter __f, _BiIter __l, size_type __n);
 
-    template <class _InpIter>
-    _LIBCPP_HIDE_FROM_ABI void __append(_InpIter __f, _InpIter __l,
-                 typename enable_if<__has_exactly_input_iterator_category<_InpIter>::value>::type* = 0);
-    template <class _ForIter>
-    _LIBCPP_HIDE_FROM_ABI void __append(_ForIter __f, _ForIter __l,
-                      typename enable_if<__has_forward_iterator_category<_ForIter>::value>::type* = 0);
+    template <class _InpIter, __enable_if_t<__has_exactly_input_iterator_category<_InpIter>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI void __append(_InpIter __f, _InpIter __l);
+    template <class _ForIter, __enable_if_t<__has_forward_iterator_category<_ForIter>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI void __append(_ForIter __f, _ForIter __l);
 
     template <class _InputIterator>
     _LIBCPP_HIDE_FROM_ABI void __append_with_size(_InputIterator __from, size_type __n);
@@ -1377,9 +1367,8 @@ deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v)
 }
 
 template <class _Tp, class _Allocator>
-template <class _InputIter>
-deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l,
-              typename enable_if<__has_input_iterator_category<_InputIter>::value>::type*)
+template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
+deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l)
     : __start_(0), __size_(0, __default_init_tag())
 {
     __annotate_new(0);
@@ -1387,9 +1376,8 @@ deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l,
 }
 
 template <class _Tp, class _Allocator>
-template <class _InputIter>
-deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
-              typename enable_if<__has_input_iterator_category<_InputIter>::value>::type*)
+template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
+deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a)
     : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a)
 {
     __annotate_new(0);
@@ -1514,11 +1502,10 @@ deque<_Tp, _Allocator>::__move_assign(deque& __c, true_type)
 #endif // _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Allocator>
-template <class _InputIter>
+template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value &&
+                                          !__has_random_access_iterator_category<_InputIter>::value, int> >
 void
-deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l,
-                               typename enable_if<__has_input_iterator_category<_InputIter>::value &&
-                                                 !__has_random_access_iterator_category<_InputIter>::value>::type*)
+deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l)
 {
   __assign_with_sentinel(__f, __l);
 }
@@ -1538,10 +1525,9 @@ void deque<_Tp, _Allocator>::__assign_with_sentinel(_Iterator __f, _Sentinel __l
 }
 
 template <class _Tp, class _Allocator>
-template <class _RAIter>
+template <class _RAIter, __enable_if_t<__has_random_access_iterator_category<_RAIter>::value, int> >
 void
-deque<_Tp, _Allocator>::assign(_RAIter __f, _RAIter __l,
-                               typename enable_if<__has_random_access_iterator_category<_RAIter>::value>::type*)
+deque<_Tp, _Allocator>::assign(_RAIter __f, _RAIter __l)
 {
   __assign_with_size_random_access(__f, __l - __f);
 }
@@ -2064,10 +2050,9 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty
 }
 
 template <class _Tp, class _Allocator>
-template <class _InputIter>
+template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> >
 typename deque<_Tp, _Allocator>::iterator
-deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l,
-                               typename enable_if<__has_exactly_input_iterator_category<_InputIter>::value>::type*)
+deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l)
 {
   return __insert_with_sentinel(__p, __f, __l);
 }
@@ -2084,10 +2069,9 @@ deque<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __p, _Iterator __f
 }
 
 template <class _Tp, class _Allocator>
-template <class _ForwardIterator>
+template <class _ForwardIterator, __enable_if_t<__has_exactly_forward_iterator_category<_ForwardIterator>::value, int> >
 typename deque<_Tp, _Allocator>::iterator
-deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
-                               typename enable_if<__has_exactly_forward_iterator_category<_ForwardIterator>::value>::type*)
+deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l)
 {
   return __insert_with_size(__p, __f, std::distance(__f, __l));
 }
@@ -2104,10 +2088,9 @@ deque<_Tp, _Allocator>::__insert_with_size(const_iterator __p, _Iterator __f, si
 }
 
 template <class _Tp, class _Allocator>
-template <class _BiIter>
+template <class _BiIter, __enable_if_t<__has_bidirectional_iterator_category<_BiIter>::value, int> >
 typename deque<_Tp, _Allocator>::iterator
-deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
-                               typename enable_if<__has_bidirectional_iterator_category<_BiIter>::value>::type*)
+deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l)
 {
   return __insert_bidirectional(__p, __f, __l, std::distance(__f, __l));
 }
@@ -2190,10 +2173,9 @@ deque<_Tp, _Allocator>::__insert_bidirectional(const_iterator __p, _BiIter __f,
 }
 
 template <class _Tp, class _Allocator>
-template <class _InpIter>
+template <class _InpIter, __enable_if_t<__has_exactly_input_iterator_category<_InpIter>::value, int> >
 void
-deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l,
-                                 typename enable_if<__has_exactly_input_iterator_category<_InpIter>::value>::type*)
+deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l)
 {
   __append_with_sentinel(__f, __l);
 }
@@ -2211,10 +2193,9 @@ void deque<_Tp, _Allocator>::__append_with_sentinel(_InputIterator __f, _Sentine
 }
 
 template <class _Tp, class _Allocator>
-template <class _ForIter>
+template <class _ForIter, __enable_if_t<__has_forward_iterator_category<_ForIter>::value, int> >
 void
-deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l,
-                                 typename enable_if<__has_forward_iterator_category<_ForIter>::value>::type*)
+deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l)
 {
     __append_with_size(__f, std::distance(__f, __l));
 }

diff  --git a/libcxx/include/vector b/libcxx/include/vector
index 08a5d8bc97c056..6d26ce169b600a 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -2142,18 +2142,14 @@ public:
 #endif
     _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v);
     _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v, const allocator_type& __a);
-    template <class _InputIterator>
-    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last,
-               typename enable_if<__has_exactly_input_iterator_category<_InputIterator>::value>::type* = 0);
-    template <class _InputIterator>
-    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
-               typename enable_if<__has_exactly_input_iterator_category<_InputIterator>::value>::type* = 0);
-    template <class _ForwardIterator>
-    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last,
-               typename enable_if<__has_forward_iterator_category<_ForwardIterator>::value>::type* = 0);
-    template <class _ForwardIterator>
-    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
-               typename enable_if<__has_forward_iterator_category<_ForwardIterator>::value>::type* = 0);
+    template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last);
+    template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
+    template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
+    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);
 
 #if _LIBCPP_STD_VER >= 23
     template <_ContainerCompatibleRange<bool> _Range>
@@ -2685,10 +2681,9 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all
 }
 
 template <class _Allocator>
-template <class _InputIterator>
+template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
 _LIBCPP_CONSTEXPR_SINCE_CXX20
-vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
-       typename enable_if<__has_exactly_input_iterator_category<_InputIterator>::value>::type*)
+vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last)
     : __begin_(nullptr),
       __size_(0),
       __cap_alloc_(0, __default_init_tag())
@@ -2697,10 +2692,9 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
 }
 
 template <class _Allocator>
-template <class _InputIterator>
+template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
 _LIBCPP_CONSTEXPR_SINCE_CXX20
-vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
-       typename enable_if<__has_exactly_input_iterator_category<_InputIterator>::value>::type*)
+vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
     : __begin_(nullptr),
       __size_(0),
       __cap_alloc_(0, static_cast<__storage_allocator>(__a))
@@ -2709,10 +2703,9 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
 }
 
 template <class _Allocator>
-template <class _ForwardIterator>
+template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
 _LIBCPP_CONSTEXPR_SINCE_CXX20
-vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
-                                typename enable_if<__has_forward_iterator_category<_ForwardIterator>::value>::type*)
+vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last)
     : __begin_(nullptr),
       __size_(0),
       __cap_alloc_(0, __default_init_tag())
@@ -2722,10 +2715,9 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
 }
 
 template <class _Allocator>
-template <class _ForwardIterator>
+template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
 _LIBCPP_CONSTEXPR_SINCE_CXX20
-vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
-                                typename enable_if<__has_forward_iterator_category<_ForwardIterator>::value>::type*)
+vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)
     : __begin_(nullptr),
       __size_(0),
       __cap_alloc_(0, static_cast<__storage_allocator>(__a))


        


More information about the libcxx-commits mailing list