[libcxx-commits] [libcxx] [libc++] Simplify __promote (PR #136101)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 7 08:04:04 PDT 2025


================
@@ -10,37 +10,30 @@
 #define _LIBCPP___TYPE_TRAITS_PROMOTE_H
 
 #include <__config>
-#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_arithmetic.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template <class... _Args>
-class __promote {
-  static_assert((is_arithmetic<_Args>::value && ...));
-
-  static float __test(float);
-  static double __test(char);
-  static double __test(int);
-  static double __test(unsigned);
-  static double __test(long);
-  static double __test(unsigned long);
-  static double __test(long long);
-  static double __test(unsigned long long);
+float __promote_impl(float);
+double __promote_impl(char);
+double __promote_impl(int);
+double __promote_impl(unsigned);
+double __promote_impl(long);
+double __promote_impl(unsigned long);
+double __promote_impl(long long);
+double __promote_impl(unsigned long long);
 #if _LIBCPP_HAS_INT128
-  static double __test(__int128_t);
-  static double __test(__uint128_t);
+double __promote_impl(__int128_t);
+double __promote_impl(__uint128_t);
 #endif
-  static double __test(double);
-  static long double __test(long double);
+double __promote_impl(double);
+long double __promote_impl(long double);
 
-public:
-  using type = decltype((__test(_Args()) + ...));
-};
+template <class... _Args>
+using __promote_t _LIBCPP_NODEBUG = decltype((std::__promote_impl(_Args()) + ...));
----------------
ldionne wrote:

It would be nice not to drop the `static_assert`.

https://github.com/llvm/llvm-project/pull/136101


More information about the libcxx-commits mailing list