[libcxx-commits] [libcxx] dbdbb8d - [libc++] Simplify the implementation of conditional a bit (#199916)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 28 03:59:41 PDT 2026
Author: Nikolas Klauser
Date: 2026-05-28T12:59:36+02:00
New Revision: dbdbb8d6afd8d30a0074ee0aadc2dbf81c0e8d02
URL: https://github.com/llvm/llvm-project/commit/dbdbb8d6afd8d30a0074ee0aadc2dbf81c0e8d02
DIFF: https://github.com/llvm/llvm-project/commit/dbdbb8d6afd8d30a0074ee0aadc2dbf81c0e8d02.diff
LOG: [libc++] Simplify the implementation of conditional a bit (#199916)
We can use our internal `_If` instead of specializing `conditional` for
selecting the appropriate type.
Added:
Modified:
libcxx/include/__type_traits/conditional.h
Removed:
################################################################################
diff --git a/libcxx/include/__type_traits/conditional.h b/libcxx/include/__type_traits/conditional.h
index 71882fb1917b1..0daa7737bed06 100644
--- a/libcxx/include/__type_traits/conditional.h
+++ b/libcxx/include/__type_traits/conditional.h
@@ -35,20 +35,10 @@ struct _IfImpl<false> {
template <bool _Cond, class _IfRes, class _ElseRes>
using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>;
-template <bool _Bp, class _If, class _Then>
+template <bool _Bp, class _IfRes, class _ElseRes>
struct _LIBCPP_NO_SPECIALIZATIONS conditional {
- using type _LIBCPP_NODEBUG = _If;
-};
-
-_LIBCPP_DIAGNOSTIC_PUSH
-#if __has_warning("-Winvalid-specialization")
-_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
-#endif
-template <class _If, class _Then>
-struct conditional<false, _If, _Then> {
- using type _LIBCPP_NODEBUG = _Then;
+ using type _LIBCPP_NODEBUG = _If<_Bp, _IfRes, _ElseRes>;
};
-_LIBCPP_DIAGNOSTIC_POP
#if _LIBCPP_STD_VER >= 14
template <bool _Bp, class _IfRes, class _ElseRes>
More information about the libcxx-commits
mailing list