File: test_promote_args.cpp

package info (click to toggle)
scipy 1.16.0-1exp7
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 234,820 kB
  • sloc: cpp: 503,145; python: 344,611; ansic: 195,638; javascript: 89,566; fortran: 56,210; cs: 3,081; f90: 1,150; sh: 848; makefile: 785; pascal: 284; csh: 135; lisp: 134; xml: 56; perl: 51
file content (188 lines) | stat: -rw-r--r-- 8,257 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// Copyright John Maddock 2023.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/math/tools/promotion.hpp>
#ifndef BOOST_MATH_STANDALONE
#include <boost/multiprecision/cpp_bin_float.hpp>
#endif
#include <type_traits>

#if __has_include(<stdfloat>)
#  include <stdfloat>
#endif

int main() 
{
   using boost::math::tools::promote_args_t;

#if defined(__cpp_lib_type_trait_variable_templates) && (__cpp_lib_type_trait_variable_templates >= 201510L) && defined(__cpp_static_assert) && (__cpp_static_assert >= 201411L)

   static_assert(std::is_same_v<promote_args_t<long double, float>, long double>);
   static_assert(std::is_same_v<promote_args_t<long double, double>, long double>);
   static_assert(std::is_same_v<promote_args_t<long double, long double>, long double>);
#ifdef __STDCPP_FLOAT16_T__
   static_assert(std::is_same_v<promote_args_t<long double, std::float16_t>, long double>);
#endif
#ifdef __STDCPP_FLOAT32_T__
   static_assert(std::is_same_v<promote_args_t<long double, std::float32_t>, long double>);
#endif
#ifdef __STDCPP_FLOAT64_T__
#if LDBL_MANT_DIG > 53
   static_assert(std::is_same_v<promote_args_t<long double, std::float64_t>, long double>);
#else
   static_assert(std::is_same_v<promote_args_t<long double, std::float64_t>, std::float64_t>);
#endif
#endif
#ifdef __STDCPP_FLOAT128_T__
#if LDBL_MANT_DIG > 113
   static_assert(std::is_same_v<promote_args_t<long double, std::float128_t>, long double>);
#else
   static_assert(std::is_same_v<promote_args_t<long double, std::float128_t>, std::float128_t>);
#endif
#endif
   
   static_assert(std::is_same_v<promote_args_t<double, float>, double>);
   static_assert(std::is_same_v<promote_args_t<double, double>, double>);
   static_assert(std::is_same_v<promote_args_t<double, long double>, long double>);
#ifdef __STDCPP_FLOAT16_T__
   static_assert(std::is_same_v<promote_args_t<double, std::float16_t>, double>);
#endif
#ifdef __STDCPP_FLOAT32_T__
   static_assert(std::is_same_v<promote_args_t<double, std::float32_t>, double>);
#endif
#ifdef __STDCPP_FLOAT64_T__
#if DBL_MANT_DIG > 53
   static_assert(std::is_same_v<promote_args_t<double, std::float64_t>, double>);
#else
   static_assert(std::is_same_v<promote_args_t<double, std::float64_t>, std::float64_t>);
#endif
#endif
#ifdef __STDCPP_FLOAT128_T__
#if DBL_MANT_DIG > 113
   static_assert(std::is_same_v<promote_args_t<double, std::float128_t>, double>);
#else
   static_assert(std::is_same_v<promote_args_t<double, std::float128_t>, std::float128_t>);
#endif
#endif
   
   static_assert(std::is_same_v<promote_args_t<float, float>, float>);
   static_assert(std::is_same_v<promote_args_t<float, double>, double>);
   static_assert(std::is_same_v<promote_args_t<float, long double>, long double>);
#ifdef __STDCPP_FLOAT16_T__
   static_assert(std::is_same_v<promote_args_t<float, std::float16_t>, float>);
#endif
#ifdef __STDCPP_FLOAT32_T__
   static_assert(std::is_same_v<promote_args_t<float, std::float32_t>, std::float32_t>);
#endif
#ifdef __STDCPP_FLOAT64_T__
   static_assert(std::is_same_v<promote_args_t<float, std::float64_t>, std::float64_t>);
#endif
#ifdef __STDCPP_FLOAT128_T__
   static_assert(std::is_same_v<promote_args_t<float, std::float128_t>, std::float128_t>);
#endif
   
#ifdef __STDCPP_FLOAT16_T__
   static_assert(std::is_same_v<promote_args_t<std::float16_t, float>, float>);
   static_assert(std::is_same_v<promote_args_t<std::float16_t, double>, double>);
   static_assert(std::is_same_v<promote_args_t<std::float16_t, long double>, long double>);
#ifdef __STDCPP_FLOAT16_T__
   static_assert(std::is_same_v<promote_args_t<std::float16_t, std::float16_t>, float>);
#endif
#ifdef __STDCPP_FLOAT32_T__
   static_assert(std::is_same_v<promote_args_t<std::float16_t, std::float32_t>, std::float32_t>);
#endif
#ifdef __STDCPP_FLOAT64_T__
   static_assert(std::is_same_v<promote_args_t<std::float16_t, std::float64_t>, std::float64_t>);
#endif
#ifdef __STDCPP_FLOAT128_T__
   static_assert(std::is_same_v<promote_args_t<std::float16_t, std::float128_t>, std::float128_t>);
#endif
#endif   

#ifdef __STDCPP_FLOAT32_T__
   static_assert(std::is_same_v<promote_args_t<std::float32_t, float>, std::float32_t>);
   static_assert(std::is_same_v<promote_args_t<std::float32_t, double>, double>);
   static_assert(std::is_same_v<promote_args_t<std::float32_t, long double>, long double>);
#ifdef __STDCPP_FLOAT16_T__
   static_assert(std::is_same_v<promote_args_t<std::float32_t, std::float16_t>, std::float32_t>);
#endif
#ifdef __STDCPP_FLOAT32_T__
   static_assert(std::is_same_v<promote_args_t<std::float32_t, std::float32_t>, std::float32_t>);
#endif
#ifdef __STDCPP_FLOAT64_T__
   static_assert(std::is_same_v<promote_args_t<std::float32_t, std::float64_t>, std::float64_t>);
#endif
#ifdef __STDCPP_FLOAT128_T__
   static_assert(std::is_same_v<promote_args_t<std::float32_t, std::float128_t>, std::float128_t>);
#endif
#endif   

#ifdef __STDCPP_FLOAT64_T__
   static_assert(std::is_same_v<promote_args_t<std::float64_t, float>, std::float64_t>);
   static_assert(std::is_same_v<promote_args_t<std::float64_t, double>, std::float64_t>);
#if LDBL_MANT_DIG > 53
   static_assert(std::is_same_v<promote_args_t<std::float64_t, long double>, long double>);
#else
   static_assert(std::is_same_v<promote_args_t<std::float64_t, long double>, std::float64_t>);
#endif
#ifdef __STDCPP_FLOAT16_T__
   static_assert(std::is_same_v<promote_args_t<std::float64_t, std::float16_t>, std::float64_t>);
#endif
#ifdef __STDCPP_FLOAT32_T__
   static_assert(std::is_same_v<promote_args_t<std::float64_t, std::float32_t>, std::float64_t>);
#endif
#ifdef __STDCPP_FLOAT64_T__
   static_assert(std::is_same_v<promote_args_t<std::float64_t, std::float64_t>, std::float64_t>);
#endif
#ifdef __STDCPP_FLOAT128_T__
   static_assert(std::is_same_v<promote_args_t<std::float64_t, std::float128_t>, std::float128_t>);
#endif
#endif   

#ifdef __STDCPP_FLOAT128_T__
   static_assert(std::is_same_v<promote_args_t<std::float128_t, float>, std::float128_t>);
   static_assert(std::is_same_v<promote_args_t<std::float128_t, double>, std::float128_t>);
#if LDBL_MANT_DIG > 113
   static_assert(std::is_same_v<promote_args_t<std::float128_t, long double>, long double>);
#else
   static_assert(std::is_same_v<promote_args_t<std::float128_t, long double>, std::float128_t>);
#endif
#ifdef __STDCPP_FLOAT16_T__
   static_assert(std::is_same_v<promote_args_t<std::float128_t, std::float16_t>, std::float128_t>);
#endif
#ifdef __STDCPP_FLOAT32_T__
   static_assert(std::is_same_v<promote_args_t<std::float128_t, std::float32_t>, std::float128_t>);
#endif
#ifdef __STDCPP_FLOAT64_T__
   static_assert(std::is_same_v<promote_args_t<std::float128_t, std::float64_t>, std::float128_t>);
#endif
#ifdef __STDCPP_FLOAT128_T__
   static_assert(std::is_same_v<promote_args_t<std::float128_t, std::float128_t>, std::float128_t>);
#endif
#endif   

#ifndef BOOST_MATH_STANDALONE
   static_assert(std::is_same_v<promote_args_t<float, boost::multiprecision::cpp_bin_float_50>, boost::multiprecision::cpp_bin_float_50>);
   static_assert(std::is_same_v<promote_args_t<double, boost::multiprecision::cpp_bin_float_50>, boost::multiprecision::cpp_bin_float_50>);
   static_assert(std::is_same_v<promote_args_t<long double, boost::multiprecision::cpp_bin_float_50>, boost::multiprecision::cpp_bin_float_50>);
#ifdef __STDCPP_FLOAT16_T__
   static_assert(std::is_same_v<promote_args_t<std::float16_t, boost::multiprecision::cpp_bin_float_50>, boost::multiprecision::cpp_bin_float_50>);
#endif
#ifdef __STDCPP_FLOAT32_T__
   static_assert(std::is_same_v<promote_args_t<std::float32_t, boost::multiprecision::cpp_bin_float_50>, boost::multiprecision::cpp_bin_float_50>);
#endif
#ifdef __STDCPP_FLOAT64_T__
   static_assert(std::is_same_v<promote_args_t<std::float64_t, boost::multiprecision::cpp_bin_float_50>, boost::multiprecision::cpp_bin_float_50>);
#endif
#ifdef __STDCPP_FLOAT128_T__
   static_assert(std::is_same_v<promote_args_t<std::float128_t, boost::multiprecision::cpp_bin_float_50>, boost::multiprecision::cpp_bin_float_50>);
#endif
#endif // BOOST_MATH_STANDALONE

#endif

   return 0;
}