1313#include < __type_traits/integral_constant.h>
1414#include < __type_traits/is_arithmetic.h>
1515
16- #if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER == 1700
17- # include < __type_traits/is_same.h>
18- # include < __utility/declval.h>
19- #endif
20-
2116#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2217# pragma GCC system_header
2318#endif
2419
2520_LIBCPP_BEGIN_NAMESPACE_STD
2621
27- // TODO(LLVM-20): Remove this workaround
28- #if !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER != 1700
29-
3022template <class ... _Args>
3123class __promote {
3224 static_assert ((is_arithmetic<_Args>::value && ...));
@@ -39,90 +31,17 @@ class __promote {
3931 static double __test (unsigned long );
4032 static double __test (long long );
4133 static double __test (unsigned long long );
42- # if _LIBCPP_HAS_INT128
34+ #if _LIBCPP_HAS_INT128
4335 static double __test (__int128_t );
4436 static double __test (__uint128_t );
45- # endif
37+ #endif
4638 static double __test (double );
4739 static long double __test (long double );
4840
4941public:
5042 using type = decltype ((__test(_Args()) + ...));
5143};
5244
53- #else
54-
55- template <class _Tp >
56- struct __numeric_type {
57- static void __test (...);
58- static float __test (float );
59- static double __test (char );
60- static double __test (int );
61- static double __test (unsigned );
62- static double __test (long );
63- static double __test (unsigned long );
64- static double __test (long long );
65- static double __test (unsigned long long );
66- # if _LIBCPP_HAS_INT128
67- static double __test (__int128_t );
68- static double __test (__uint128_t );
69- # endif
70- static double __test (double );
71- static long double __test (long double );
72-
73- typedef decltype (__test(std::declval<_Tp>())) type;
74- static const bool value = _IsNotSame<type, void >::value;
75- };
76-
77- template <>
78- struct __numeric_type <void > {
79- static const bool value = true ;
80- };
81-
82- template <class _A1 ,
83- class _A2 = void ,
84- class _A3 = void ,
85- bool = __numeric_type<_A1>::value && __numeric_type<_A2>::value && __numeric_type<_A3>::value>
86- class __promote_imp {
87- public:
88- static const bool value = false ;
89- };
90-
91- template <class _A1 , class _A2 , class _A3 >
92- class __promote_imp <_A1, _A2, _A3, true > {
93- private:
94- typedef typename __promote_imp<_A1>::type __type1;
95- typedef typename __promote_imp<_A2>::type __type2;
96- typedef typename __promote_imp<_A3>::type __type3;
97-
98- public:
99- typedef decltype (__type1() + __type2() + __type3()) type;
100- static const bool value = true ;
101- };
102-
103- template <class _A1 , class _A2 >
104- class __promote_imp <_A1, _A2, void , true > {
105- private:
106- typedef typename __promote_imp<_A1>::type __type1;
107- typedef typename __promote_imp<_A2>::type __type2;
108-
109- public:
110- typedef decltype (__type1() + __type2()) type;
111- static const bool value = true ;
112- };
113-
114- template <class _A1 >
115- class __promote_imp <_A1, void , void , true > {
116- public:
117- typedef typename __numeric_type<_A1>::type type;
118- static const bool value = true ;
119- };
120-
121- template <class _A1 , class _A2 = void , class _A3 = void >
122- class __promote : public __promote_imp <_A1, _A2, _A3> {};
123-
124- #endif // !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 1700
125-
12645_LIBCPP_END_NAMESPACE_STD
12746
12847#endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H
0 commit comments