Skip to content

Commit 2274c66

Browse files
authored
[libc++] Use _If for conditional_t (llvm#96193)
This avoids different instantiations when the if and else types are different, resulting in reduced memory use by the compiler.
1 parent ec9ce89 commit 2274c66

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

libcxx/include/__type_traits/conditional.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,14 @@ struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {
4444
using type _LIBCPP_NODEBUG = _Then;
4545
};
4646

47+
template <bool _Bp, class _IfRes, class _ElseRes>
48+
using __conditional_t _LIBCPP_NODEBUG = _If<_Bp, _IfRes, _ElseRes>;
49+
4750
#if _LIBCPP_STD_VER >= 14
4851
template <bool _Bp, class _IfRes, class _ElseRes>
49-
using conditional_t _LIBCPP_NODEBUG = typename conditional<_Bp, _IfRes, _ElseRes>::type;
52+
using conditional_t _LIBCPP_NODEBUG = __conditional_t<_Bp, _IfRes, _ElseRes>;
5053
#endif
5154

52-
// Helper so we can use "conditional_t" in all language versions.
53-
template <bool _Bp, class _If, class _Then>
54-
using __conditional_t _LIBCPP_NODEBUG = typename conditional<_Bp, _If, _Then>::type;
55-
5655
_LIBCPP_END_NAMESPACE_STD
5756

5857
#endif // _LIBCPP___TYPE_TRAITS_CONDITIONAL_H

0 commit comments

Comments
 (0)