xref: /llvm-project/libcxx/include/__type_traits/promote.h (revision 7f845cba2ccc2ab637b8e40fbafb9f83a2d67c70)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef _LIBCPP___TYPE_TRAITS_PROMOTE_H
10 #define _LIBCPP___TYPE_TRAITS_PROMOTE_H
11 
12 #include <__config>
13 #include <__type_traits/integral_constant.h>
14 #include <__type_traits/is_arithmetic.h>
15 
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 #  pragma GCC system_header
18 #endif
19 
20 _LIBCPP_BEGIN_NAMESPACE_STD
21 
22 template <class... _Args>
23 class __promote {
24   static_assert((is_arithmetic<_Args>::value && ...));
25 
26   static float __test(float);
27   static double __test(char);
28   static double __test(int);
29   static double __test(unsigned);
30   static double __test(long);
31   static double __test(unsigned long);
32   static double __test(long long);
33   static double __test(unsigned long long);
34 #if _LIBCPP_HAS_INT128
35   static double __test(__int128_t);
36   static double __test(__uint128_t);
37 #endif
38   static double __test(double);
39   static long double __test(long double);
40 
41 public:
42   using type = decltype((__test(_Args()) + ...));
43 };
44 
45 _LIBCPP_END_NAMESPACE_STD
46 
47 #endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H
48