Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions libcxx/include/__type_traits/promote.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,47 @@

#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
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

// TODO(LLVM-20): Remove this workaround
#if !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER != 1700

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);
# 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 <class _Tp>
struct __numeric_type {
static void __test(...);
Expand All @@ -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);

Expand Down Expand Up @@ -89,6 +121,8 @@ class __promote_imp<_A1, void, void, true> {
template <class _A1, class _A2 = void, class _A3 = void>
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