Skip to content

Commit 4814628

Browse files
authored
[libc++][NFC] Replace conditional<>::type with __conditional_t (#96745)
`__conditional_t` is move efficient than `conditional`, since it avoids instantiating a template for every type combination.
1 parent ea8e4c0 commit 4814628

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

libcxx/include/__iterator/move_iterator.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ class _LIBCPP_TEMPLATE_VIS move_iterator
105105
typedef iterator_type pointer;
106106

107107
typedef typename iterator_traits<iterator_type>::reference __reference;
108-
typedef typename conditional< is_reference<__reference>::value,
109-
__libcpp_remove_reference_t<__reference>&&,
110-
__reference >::type reference;
108+
typedef __conditional_t<is_reference<__reference>::value, __libcpp_remove_reference_t<__reference>&&, __reference>
109+
reference;
111110
#endif // _LIBCPP_STD_VER >= 20
112111

113112
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit move_iterator(_Iter __i) : __current_(std::move(__i)) {}

libcxx/include/__type_traits/common_type.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> : public common_type<_Tp, _Tp> {};
8282
// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
8383
template <class _Tp, class _Up>
8484
struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
85-
: conditional<_IsSame<_Tp, __decay_t<_Tp> >::value && _IsSame<_Up, __decay_t<_Up> >::value,
86-
__common_type2_imp<_Tp, _Up>,
87-
common_type<__decay_t<_Tp>, __decay_t<_Up> > >::type {};
85+
: __conditional_t<_IsSame<_Tp, __decay_t<_Tp> >::value && _IsSame<_Up, __decay_t<_Up> >::value,
86+
__common_type2_imp<_Tp, _Up>,
87+
common_type<__decay_t<_Tp>, __decay_t<_Up> > > {};
8888

8989
// bullet 4 - sizeof...(Tp) > 2
9090

libcxx/include/__type_traits/decay.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ struct __decay {
4343
template <class _Up>
4444
struct __decay<_Up, true> {
4545
public:
46-
typedef _LIBCPP_NODEBUG typename conditional<
47-
is_array<_Up>::value,
48-
__add_pointer_t<__remove_extent_t<_Up> >,
49-
typename conditional<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> >::type >::type
50-
type;
46+
typedef _LIBCPP_NODEBUG
47+
__conditional_t<is_array<_Up>::value,
48+
__add_pointer_t<__remove_extent_t<_Up> >,
49+
__conditional_t<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> > >
50+
type;
5151
};
5252

5353
template <class _Tp>

0 commit comments

Comments
 (0)