[libcxx-commits] [libcxx] [libc++] Use _If for conditional_t (PR #96193)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jun 23 05:44:05 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Nikolas Klauser (philnik777)
<details>
<summary>Changes</summary>
This avoids different instantiations when the if and else types are different, resulting in reduced memory use by the compiler.
---
Full diff: https://github.com/llvm/llvm-project/pull/96193.diff
1 Files Affected:
- (modified) libcxx/include/__type_traits/conditional.h (+4-5)
``````````diff
diff --git a/libcxx/include/__type_traits/conditional.h b/libcxx/include/__type_traits/conditional.h
index 5b5445a837427..7d5849ee824e3 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
``````````
</details>
https://github.com/llvm/llvm-project/pull/96193
More information about the libcxx-commits
mailing list