From 4887d047a31fa89735f36ae03b697abbbd71f0dc Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Mon, 4 Jul 2022 01:21:44 +0200 Subject: [PATCH] [libc++][NFC] Replace enable_if with __enable_if_t in a few places Reviewed By: ldionne, #libc Spies: jloser, libcxx-commits Differential Revision: https://reviews.llvm.org/D128400 --- libcxx/include/__hash_table | 16 ++++------- libcxx/include/__mutex_base | 12 ++------ libcxx/include/__split_buffer | 26 +++--------------- libcxx/include/__tree | 32 +++++++-------------- libcxx/include/__tuple | 6 ++-- libcxx/include/array | 7 +---- libcxx/include/exception | 4 +-- libcxx/include/forward_list | 42 ++++++---------------------- libcxx/include/list | 16 +++++------ libcxx/include/map | 52 +++++++++++++++++------------------ libcxx/include/tuple | 16 ++--------- libcxx/include/unordered_map | 12 ++++---- 12 files changed, 77 insertions(+), 164 deletions(-) diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table index 20223014432f..036b0dcadc71 100644 --- a/libcxx/include/__hash_table +++ b/libcxx/include/__hash_table @@ -178,16 +178,14 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > { template _LIBCPP_INLINE_VISIBILITY - static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value, - __container_value_type const&>::type + static __enable_if_t<__is_same_uncvref<_Up, __node_value_type>::value, __container_value_type const&> __get_value(_Up& __t) { return __t.__get_value(); } template _LIBCPP_INLINE_VISIBILITY - static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value, - __container_value_type const&>::type + static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, __container_value_type const&> __get_value(_Up& __t) { return __t; } @@ -1049,10 +1047,8 @@ public: template _LIBCPP_INLINE_VISIBILITY - typename enable_if< - __can_extract_map_key<_First, key_type, __container_value_type>::value, - pair - >::type __emplace_unique(_First&& __f, _Second&& __s) { + __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, pair > + __emplace_unique(_First&& __f, _Second&& __s) { return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f), _VSTD::forward<_Second>(__s)); } @@ -1096,9 +1092,7 @@ public: return __emplace_unique_key_args(_NodeTypes::__get_key(__x), _VSTD::move(__x)); } - template ::value - >::type> + template ::value> > _LIBCPP_INLINE_VISIBILITY pair __insert_unique(_Pp&& __x) { return __emplace_unique(_VSTD::forward<_Pp>(__x)); diff --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base index da056b6d1423..ac0d090b7d19 100644 --- a/libcxx/include/__mutex_base +++ b/libcxx/include/__mutex_base @@ -338,11 +338,7 @@ private: template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_floating_point<_Rep>::value, - chrono::nanoseconds ->::type +__enable_if_t::value, chrono::nanoseconds> __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) { using namespace chrono; @@ -365,11 +361,7 @@ __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_floating_point<_Rep>::value, - chrono::nanoseconds ->::type +__enable_if_t::value, chrono::nanoseconds> __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) { using namespace chrono; diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer index e484e70440c9..c1c03dd741b0 100644 --- a/libcxx/include/__split_buffer +++ b/libcxx/include/__split_buffer @@ -118,19 +118,10 @@ public: void __construct_at_end(size_type __n); void __construct_at_end(size_type __n, const_reference __x); template - typename enable_if - < - __is_cpp17_input_iterator<_InputIter>::value && - !__is_cpp17_forward_iterator<_InputIter>::value, - void - >::type + __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value && !__is_cpp17_forward_iterator<_InputIter>::value> __construct_at_end(_InputIter __first, _InputIter __last); template - typename enable_if - < - __is_cpp17_forward_iterator<_ForwardIterator>::value, - void - >::type + __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value> __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin) @@ -239,12 +230,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen template template -typename enable_if -< - __is_cpp17_input_iterator<_InputIter>::value && - !__is_cpp17_forward_iterator<_InputIter>::value, - void ->::type +__enable_if_t<__is_cpp17_input_iterator<_InputIter>::value && !__is_cpp17_forward_iterator<_InputIter>::value> __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) { __alloc_rr& __a = this->__alloc(); @@ -267,11 +253,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt template template -typename enable_if -< - __is_cpp17_forward_iterator<_ForwardIterator>::value, - void ->::type +__enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value> __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) { _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last)); diff --git a/libcxx/include/__tree b/libcxx/include/__tree index e5dd1f4d45ea..8d8449706871 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -597,8 +597,7 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > { template _LIBCPP_INLINE_VISIBILITY - static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value, - key_type const&>::type + static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, key_type const&> __get_key(_Up& __t) { return __t.first; } @@ -611,8 +610,7 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > { template _LIBCPP_INLINE_VISIBILITY - static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value, - __container_value_type const&>::type + static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, __container_value_type const&> __get_value(_Up& __t) { return __t; } @@ -1175,10 +1173,8 @@ public: template _LIBCPP_INLINE_VISIBILITY - typename enable_if< - __can_extract_map_key<_First, key_type, __container_value_type>::value, - pair - >::type __emplace_unique(_First&& __f, _Second&& __s) { + __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, pair > + __emplace_unique(_First&& __f, _Second&& __s) { return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f), _VSTD::forward<_Second>(__s)); } @@ -1219,10 +1215,8 @@ public: template _LIBCPP_INLINE_VISIBILITY - typename enable_if< - __can_extract_map_key<_First, key_type, __container_value_type>::value, - iterator - >::type __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) { + __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, iterator> + __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) { return __emplace_hint_unique_key_args(__p, __f, _VSTD::forward<_First>(__f), _VSTD::forward<_Second>(__s)).first; @@ -1275,21 +1269,15 @@ public: return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v)).first; } - template ::type, - __container_value_type - >::value - >::type> + template ::type, __container_value_type>::value> > _LIBCPP_INLINE_VISIBILITY pair __insert_unique(_Vp&& __v) { return __emplace_unique(_VSTD::forward<_Vp>(__v)); } - template ::type, - __container_value_type - >::value - >::type> + template ::type, __container_value_type>::value> > _LIBCPP_INLINE_VISIBILITY iterator __insert_unique(const_iterator __p, _Vp&& __v) { return __emplace_hint_unique(__p, _VSTD::forward<_Vp>(__v)); diff --git a/libcxx/include/__tuple b/libcxx/include/__tuple index 6d13bb24c579..f85036e7af1d 100644 --- a/libcxx/include/__tuple +++ b/libcxx/include/__tuple @@ -30,14 +30,14 @@ using __enable_if_tuple_size_imp = _Tp; template struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< const _Tp, - typename enable_if::value>::type, + __enable_if_t::value>, integral_constant)>>> : public integral_constant::value> {}; template struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< volatile _Tp, - typename enable_if::value>::type, + __enable_if_t::value>, integral_constant)>>> : public integral_constant::value> {}; @@ -393,7 +393,7 @@ struct __tuple_sfinae_base { template