aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolas Klauser <nikolasklauser@berlin.de>2024-06-25 16:53:17 +0200
committerGitHub <noreply@github.com>2024-06-25 16:53:17 +0200
commit2274c66e6faaaf29ad693b1ae3e5a7b0228a1950 (patch)
tree67df0fbf7d8c85c0edf486be8e9c17dd4507b557
parentec9ce89a0823165e245be8fc095da8a88fb4cf79 (diff)
downloadllvm-2274c66e6faaaf29ad693b1ae3e5a7b0228a1950.zip
llvm-2274c66e6faaaf29ad693b1ae3e5a7b0228a1950.tar.gz
llvm-2274c66e6faaaf29ad693b1ae3e5a7b0228a1950.tar.bz2
[libc++] Use _If for conditional_t (#96193)
This avoids different instantiations when the if and else types are different, resulting in reduced memory use by the compiler.
-rw-r--r--libcxx/include/__type_traits/conditional.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/libcxx/include/__type_traits/conditional.h b/libcxx/include/__type_traits/conditional.h
index 5b5445a..7d5849e 100644
--- a/libcxx/include/__type_traits/conditional.h
+++ b/libcxx/include/__type_traits/conditional.h
@@ -44,15 +44,14 @@ struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {
using type _LIBCPP_NODEBUG = _Then;
};
+template <bool _Bp, class _IfRes, class _ElseRes>
+using __conditional_t _LIBCPP_NODEBUG = _If<_Bp, _IfRes, _ElseRes>;
+
#if _LIBCPP_STD_VER >= 14
template <bool _Bp, class _IfRes, class _ElseRes>
-using conditional_t _LIBCPP_NODEBUG = typename conditional<_Bp, _IfRes, _ElseRes>::type;
+using conditional_t _LIBCPP_NODEBUG = __conditional_t<_Bp, _IfRes, _ElseRes>;
#endif
-// Helper so we can use "conditional_t" in all language versions.
-template <bool _Bp, class _If, class _Then>
-using __conditional_t _LIBCPP_NODEBUG = typename conditional<_Bp, _If, _Then>::type;
-
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___TYPE_TRAITS_CONDITIONAL_H