diff --git a/libcxx/include/__type_traits/promote.h b/libcxx/include/__type_traits/promote.h index e22b4a422c2c8..2b2a6843b9150 100644 --- a/libcxx/include/__type_traits/promote.h +++ b/libcxx/include/__type_traits/promote.h @@ -11,8 +11,12 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_same.h> -#include <__utility/declval.h> +#include <__type_traits/is_arithmetic.h> + +#if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER == 1700 +# include <__type_traits/is_same.h> +# include <__utility/declval.h> +#endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -20,6 +24,34 @@ _LIBCPP_BEGIN_NAMESPACE_STD +// TODO(LLVM-20): Remove this workaround +#if !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER != 1700 + +template +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); +# ifndef _LIBCPP_HAS_NO_INT128 + static double __test(__int128_t); + static double __test(__uint128_t); +# endif + static double __test(double); + static long double __test(long double); + +public: + using type = decltype((__test(_Args()) + ...)); +}; + +#else + template struct __numeric_type { static void __test(...); @@ -31,10 +63,10 @@ struct __numeric_type { static double __test(unsigned long); static double __test(long long); static double __test(unsigned long long); -#ifndef _LIBCPP_HAS_NO_INT128 +# ifndef _LIBCPP_HAS_NO_INT128 static double __test(__int128_t); static double __test(__uint128_t); -#endif +# endif static double __test(double); static long double __test(long double); @@ -89,6 +121,8 @@ class __promote_imp<_A1, void, void, true> { template class __promote : public __promote_imp<_A1, _A2, _A3> {}; +#endif // !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 1700 + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H