1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <math.h>
11
12 #include <math.h>
13 #include <type_traits>
14 #include <cassert>
15
16 #include "hexfloat.h"
17 #include "truncate_fp.h"
18
19 // convertible to int/float/double/etc
20 template <class T, int N=0>
21 struct Value {
operator TValue22 operator T () { return T(N); }
23 };
24
25 // See PR21083
26 // Ambiguous is a user-defined type that defines its own overloads of cmath
27 // functions. When the std overloads are candidates too (by using or adl),
28 // they should not interfere.
29 struct Ambiguous : std::true_type { // ADL
operator floatAmbiguous30 operator float () { return 0.f; }
operator doubleAmbiguous31 operator double () { return 0.; }
32 };
abs(Ambiguous)33 Ambiguous abs(Ambiguous){ return Ambiguous(); }
acos(Ambiguous)34 Ambiguous acos(Ambiguous){ return Ambiguous(); }
asin(Ambiguous)35 Ambiguous asin(Ambiguous){ return Ambiguous(); }
atan(Ambiguous)36 Ambiguous atan(Ambiguous){ return Ambiguous(); }
atan2(Ambiguous,Ambiguous)37 Ambiguous atan2(Ambiguous, Ambiguous){ return Ambiguous(); }
ceil(Ambiguous)38 Ambiguous ceil(Ambiguous){ return Ambiguous(); }
cos(Ambiguous)39 Ambiguous cos(Ambiguous){ return Ambiguous(); }
cosh(Ambiguous)40 Ambiguous cosh(Ambiguous){ return Ambiguous(); }
exp(Ambiguous)41 Ambiguous exp(Ambiguous){ return Ambiguous(); }
fabs(Ambiguous)42 Ambiguous fabs(Ambiguous){ return Ambiguous(); }
floor(Ambiguous)43 Ambiguous floor(Ambiguous){ return Ambiguous(); }
fmod(Ambiguous,Ambiguous)44 Ambiguous fmod(Ambiguous, Ambiguous){ return Ambiguous(); }
frexp(Ambiguous,int *)45 Ambiguous frexp(Ambiguous, int*){ return Ambiguous(); }
ldexp(Ambiguous,int)46 Ambiguous ldexp(Ambiguous, int){ return Ambiguous(); }
log(Ambiguous)47 Ambiguous log(Ambiguous){ return Ambiguous(); }
log10(Ambiguous)48 Ambiguous log10(Ambiguous){ return Ambiguous(); }
modf(Ambiguous,Ambiguous *)49 Ambiguous modf(Ambiguous, Ambiguous*){ return Ambiguous(); }
pow(Ambiguous,Ambiguous)50 Ambiguous pow(Ambiguous, Ambiguous){ return Ambiguous(); }
sin(Ambiguous)51 Ambiguous sin(Ambiguous){ return Ambiguous(); }
sinh(Ambiguous)52 Ambiguous sinh(Ambiguous){ return Ambiguous(); }
sqrt(Ambiguous)53 Ambiguous sqrt(Ambiguous){ return Ambiguous(); }
tan(Ambiguous)54 Ambiguous tan(Ambiguous){ return Ambiguous(); }
tanh(Ambiguous)55 Ambiguous tanh(Ambiguous){ return Ambiguous(); }
signbit(Ambiguous)56 Ambiguous signbit(Ambiguous){ return Ambiguous(); }
fpclassify(Ambiguous)57 Ambiguous fpclassify(Ambiguous){ return Ambiguous(); }
isfinite(Ambiguous)58 Ambiguous isfinite(Ambiguous){ return Ambiguous(); }
isnormal(Ambiguous)59 Ambiguous isnormal(Ambiguous){ return Ambiguous(); }
isgreater(Ambiguous,Ambiguous)60 Ambiguous isgreater(Ambiguous, Ambiguous){ return Ambiguous(); }
isgreaterequal(Ambiguous,Ambiguous)61 Ambiguous isgreaterequal(Ambiguous, Ambiguous){ return Ambiguous(); }
isless(Ambiguous,Ambiguous)62 Ambiguous isless(Ambiguous, Ambiguous){ return Ambiguous(); }
islessequal(Ambiguous,Ambiguous)63 Ambiguous islessequal(Ambiguous, Ambiguous){ return Ambiguous(); }
islessgreater(Ambiguous,Ambiguous)64 Ambiguous islessgreater(Ambiguous, Ambiguous){ return Ambiguous(); }
isunordered(Ambiguous,Ambiguous)65 Ambiguous isunordered(Ambiguous, Ambiguous){ return Ambiguous(); }
acosh(Ambiguous)66 Ambiguous acosh(Ambiguous){ return Ambiguous(); }
asinh(Ambiguous)67 Ambiguous asinh(Ambiguous){ return Ambiguous(); }
atanh(Ambiguous)68 Ambiguous atanh(Ambiguous){ return Ambiguous(); }
cbrt(Ambiguous)69 Ambiguous cbrt(Ambiguous){ return Ambiguous(); }
copysign(Ambiguous,Ambiguous)70 Ambiguous copysign(Ambiguous, Ambiguous){ return Ambiguous(); }
erf(Ambiguous)71 Ambiguous erf(Ambiguous){ return Ambiguous(); }
erfc(Ambiguous)72 Ambiguous erfc(Ambiguous){ return Ambiguous(); }
exp2(Ambiguous)73 Ambiguous exp2(Ambiguous){ return Ambiguous(); }
expm1(Ambiguous)74 Ambiguous expm1(Ambiguous){ return Ambiguous(); }
fdim(Ambiguous,Ambiguous)75 Ambiguous fdim(Ambiguous, Ambiguous){ return Ambiguous(); }
fma(Ambiguous,Ambiguous,Ambiguous)76 Ambiguous fma(Ambiguous, Ambiguous, Ambiguous){ return Ambiguous(); }
fmax(Ambiguous,Ambiguous)77 Ambiguous fmax(Ambiguous, Ambiguous){ return Ambiguous(); }
fmin(Ambiguous,Ambiguous)78 Ambiguous fmin(Ambiguous, Ambiguous){ return Ambiguous(); }
hypot(Ambiguous,Ambiguous)79 Ambiguous hypot(Ambiguous, Ambiguous){ return Ambiguous(); }
ilogb(Ambiguous)80 Ambiguous ilogb(Ambiguous){ return Ambiguous(); }
lgamma(Ambiguous)81 Ambiguous lgamma(Ambiguous){ return Ambiguous(); }
llrint(Ambiguous)82 Ambiguous llrint(Ambiguous){ return Ambiguous(); }
llround(Ambiguous)83 Ambiguous llround(Ambiguous){ return Ambiguous(); }
log1p(Ambiguous)84 Ambiguous log1p(Ambiguous){ return Ambiguous(); }
log2(Ambiguous)85 Ambiguous log2(Ambiguous){ return Ambiguous(); }
logb(Ambiguous)86 Ambiguous logb(Ambiguous){ return Ambiguous(); }
lrint(Ambiguous)87 Ambiguous lrint(Ambiguous){ return Ambiguous(); }
lround(Ambiguous)88 Ambiguous lround(Ambiguous){ return Ambiguous(); }
nearbyint(Ambiguous)89 Ambiguous nearbyint(Ambiguous){ return Ambiguous(); }
nextafter(Ambiguous,Ambiguous)90 Ambiguous nextafter(Ambiguous, Ambiguous){ return Ambiguous(); }
nexttoward(Ambiguous,Ambiguous)91 Ambiguous nexttoward(Ambiguous, Ambiguous){ return Ambiguous(); }
remainder(Ambiguous,Ambiguous)92 Ambiguous remainder(Ambiguous, Ambiguous){ return Ambiguous(); }
remquo(Ambiguous,Ambiguous,int *)93 Ambiguous remquo(Ambiguous, Ambiguous, int*){ return Ambiguous(); }
rint(Ambiguous)94 Ambiguous rint(Ambiguous){ return Ambiguous(); }
round(Ambiguous)95 Ambiguous round(Ambiguous){ return Ambiguous(); }
scalbln(Ambiguous,Ambiguous)96 Ambiguous scalbln(Ambiguous, Ambiguous){ return Ambiguous(); }
scalbn(Ambiguous,Ambiguous)97 Ambiguous scalbn(Ambiguous, Ambiguous){ return Ambiguous(); }
tgamma(Ambiguous)98 Ambiguous tgamma(Ambiguous){ return Ambiguous(); }
trunc(Ambiguous)99 Ambiguous trunc(Ambiguous){ return Ambiguous(); }
100
test_abs()101 void test_abs()
102 {
103 static_assert((std::is_same<decltype(abs((float)0)), float>::value), "");
104 static_assert((std::is_same<decltype(abs((double)0)), double>::value), "");
105 static_assert((std::is_same<decltype(abs((long double)0)), long double>::value), "");
106 static_assert((std::is_same<decltype(abs(Ambiguous())), Ambiguous>::value), "");
107 assert(abs(-1.) == 1);
108 }
109
test_acos()110 void test_acos()
111 {
112 static_assert((std::is_same<decltype(acos((float)0)), float>::value), "");
113 static_assert((std::is_same<decltype(acos((bool)0)), double>::value), "");
114 static_assert((std::is_same<decltype(acos((unsigned short)0)), double>::value), "");
115 static_assert((std::is_same<decltype(acos((int)0)), double>::value), "");
116 static_assert((std::is_same<decltype(acos((unsigned int)0)), double>::value), "");
117 static_assert((std::is_same<decltype(acos((long)0)), double>::value), "");
118 static_assert((std::is_same<decltype(acos((unsigned long)0)), double>::value), "");
119 static_assert((std::is_same<decltype(acos((long long)0)), double>::value), "");
120 static_assert((std::is_same<decltype(acos((unsigned long long)0)), double>::value), "");
121 static_assert((std::is_same<decltype(acos((double)0)), double>::value), "");
122 static_assert((std::is_same<decltype(acos((long double)0)), long double>::value), "");
123 static_assert((std::is_same<decltype(acosf(0)), float>::value), "");
124 static_assert((std::is_same<decltype(acosl(0)), long double>::value), "");
125 static_assert((std::is_same<decltype(acos(Ambiguous())), Ambiguous>::value), "");
126 assert(acos(1) == 0);
127 }
128
test_asin()129 void test_asin()
130 {
131 static_assert((std::is_same<decltype(asin((float)0)), float>::value), "");
132 static_assert((std::is_same<decltype(asin((bool)0)), double>::value), "");
133 static_assert((std::is_same<decltype(asin((unsigned short)0)), double>::value), "");
134 static_assert((std::is_same<decltype(asin((int)0)), double>::value), "");
135 static_assert((std::is_same<decltype(asin((unsigned int)0)), double>::value), "");
136 static_assert((std::is_same<decltype(asin((long)0)), double>::value), "");
137 static_assert((std::is_same<decltype(asin((unsigned long)0)), double>::value), "");
138 static_assert((std::is_same<decltype(asin((long long)0)), double>::value), "");
139 static_assert((std::is_same<decltype(asin((unsigned long long)0)), double>::value), "");
140 static_assert((std::is_same<decltype(asin((double)0)), double>::value), "");
141 static_assert((std::is_same<decltype(asin((long double)0)), long double>::value), "");
142 static_assert((std::is_same<decltype(asinf(0)), float>::value), "");
143 static_assert((std::is_same<decltype(asinl(0)), long double>::value), "");
144 static_assert((std::is_same<decltype(asin(Ambiguous())), Ambiguous>::value), "");
145 assert(asin(0) == 0);
146 }
147
test_atan()148 void test_atan()
149 {
150 static_assert((std::is_same<decltype(atan((float)0)), float>::value), "");
151 static_assert((std::is_same<decltype(atan((bool)0)), double>::value), "");
152 static_assert((std::is_same<decltype(atan((unsigned short)0)), double>::value), "");
153 static_assert((std::is_same<decltype(atan((int)0)), double>::value), "");
154 static_assert((std::is_same<decltype(atan((unsigned int)0)), double>::value), "");
155 static_assert((std::is_same<decltype(atan((long)0)), double>::value), "");
156 static_assert((std::is_same<decltype(atan((unsigned long)0)), double>::value), "");
157 static_assert((std::is_same<decltype(atan((long long)0)), double>::value), "");
158 static_assert((std::is_same<decltype(atan((unsigned long long)0)), double>::value), "");
159 static_assert((std::is_same<decltype(atan((double)0)), double>::value), "");
160 static_assert((std::is_same<decltype(atan((long double)0)), long double>::value), "");
161 static_assert((std::is_same<decltype(atanf(0)), float>::value), "");
162 static_assert((std::is_same<decltype(atanl(0)), long double>::value), "");
163 static_assert((std::is_same<decltype(atan(Ambiguous())), Ambiguous>::value), "");
164 assert(atan(0) == 0);
165 }
166
test_atan2()167 void test_atan2()
168 {
169 static_assert((std::is_same<decltype(atan2((float)0, (float)0)), float>::value), "");
170 static_assert((std::is_same<decltype(atan2((bool)0, (float)0)), double>::value), "");
171 static_assert((std::is_same<decltype(atan2((unsigned short)0, (double)0)), double>::value), "");
172 static_assert((std::is_same<decltype(atan2((int)0, (long double)0)), long double>::value), "");
173 static_assert((std::is_same<decltype(atan2((float)0, (unsigned int)0)), double>::value), "");
174 static_assert((std::is_same<decltype(atan2((double)0, (long)0)), double>::value), "");
175 static_assert((std::is_same<decltype(atan2((long double)0, (unsigned long)0)), long double>::value), "");
176 static_assert((std::is_same<decltype(atan2((int)0, (long long)0)), double>::value), "");
177 static_assert((std::is_same<decltype(atan2((int)0, (unsigned long long)0)), double>::value), "");
178 static_assert((std::is_same<decltype(atan2((double)0, (double)0)), double>::value), "");
179 static_assert((std::is_same<decltype(atan2((long double)0, (long double)0)), long double>::value), "");
180 static_assert((std::is_same<decltype(atan2((float)0, (double)0)), double>::value), "");
181 static_assert((std::is_same<decltype(atan2((float)0, (long double)0)), long double>::value), "");
182 static_assert((std::is_same<decltype(atan2((double)0, (long double)0)), long double>::value), "");
183 static_assert((std::is_same<decltype(atan2f(0,0)), float>::value), "");
184 static_assert((std::is_same<decltype(atan2l(0,0)), long double>::value), "");
185 static_assert((std::is_same<decltype(atan2((int)0, (int)0)), double>::value), "");
186 static_assert((std::is_same<decltype(atan2(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
187 assert(atan2(0,1) == 0);
188 }
189
test_ceil()190 void test_ceil()
191 {
192 static_assert((std::is_same<decltype(ceil((float)0)), float>::value), "");
193 static_assert((std::is_same<decltype(ceil((bool)0)), double>::value), "");
194 static_assert((std::is_same<decltype(ceil((unsigned short)0)), double>::value), "");
195 static_assert((std::is_same<decltype(ceil((int)0)), double>::value), "");
196 static_assert((std::is_same<decltype(ceil((unsigned int)0)), double>::value), "");
197 static_assert((std::is_same<decltype(ceil((long)0)), double>::value), "");
198 static_assert((std::is_same<decltype(ceil((unsigned long)0)), double>::value), "");
199 static_assert((std::is_same<decltype(ceil((long long)0)), double>::value), "");
200 static_assert((std::is_same<decltype(ceil((unsigned long long)0)), double>::value), "");
201 static_assert((std::is_same<decltype(ceil((double)0)), double>::value), "");
202 static_assert((std::is_same<decltype(ceil((long double)0)), long double>::value), "");
203 static_assert((std::is_same<decltype(ceilf(0)), float>::value), "");
204 static_assert((std::is_same<decltype(ceill(0)), long double>::value), "");
205 static_assert((std::is_same<decltype(ceil(Ambiguous())), Ambiguous>::value), "");
206 assert(ceil(0) == 0);
207 }
208
test_cos()209 void test_cos()
210 {
211 static_assert((std::is_same<decltype(cos((float)0)), float>::value), "");
212 static_assert((std::is_same<decltype(cos((bool)0)), double>::value), "");
213 static_assert((std::is_same<decltype(cos((unsigned short)0)), double>::value), "");
214 static_assert((std::is_same<decltype(cos((int)0)), double>::value), "");
215 static_assert((std::is_same<decltype(cos((unsigned int)0)), double>::value), "");
216 static_assert((std::is_same<decltype(cos((long)0)), double>::value), "");
217 static_assert((std::is_same<decltype(cos((unsigned long)0)), double>::value), "");
218 static_assert((std::is_same<decltype(cos((long long)0)), double>::value), "");
219 static_assert((std::is_same<decltype(cos((unsigned long long)0)), double>::value), "");
220 static_assert((std::is_same<decltype(cos((double)0)), double>::value), "");
221 static_assert((std::is_same<decltype(cos((long double)0)), long double>::value), "");
222 static_assert((std::is_same<decltype(cosf(0)), float>::value), "");
223 static_assert((std::is_same<decltype(cosl(0)), long double>::value), "");
224 static_assert((std::is_same<decltype(cos(Ambiguous())), Ambiguous>::value), "");
225 assert(cos(0) == 1);
226 }
227
test_cosh()228 void test_cosh()
229 {
230 static_assert((std::is_same<decltype(cosh((float)0)), float>::value), "");
231 static_assert((std::is_same<decltype(cosh((bool)0)), double>::value), "");
232 static_assert((std::is_same<decltype(cosh((unsigned short)0)), double>::value), "");
233 static_assert((std::is_same<decltype(cosh((int)0)), double>::value), "");
234 static_assert((std::is_same<decltype(cosh((unsigned int)0)), double>::value), "");
235 static_assert((std::is_same<decltype(cosh((long)0)), double>::value), "");
236 static_assert((std::is_same<decltype(cosh((unsigned long)0)), double>::value), "");
237 static_assert((std::is_same<decltype(cosh((long long)0)), double>::value), "");
238 static_assert((std::is_same<decltype(cosh((unsigned long long)0)), double>::value), "");
239 static_assert((std::is_same<decltype(cosh((double)0)), double>::value), "");
240 static_assert((std::is_same<decltype(cosh((long double)0)), long double>::value), "");
241 static_assert((std::is_same<decltype(coshf(0)), float>::value), "");
242 static_assert((std::is_same<decltype(coshl(0)), long double>::value), "");
243 static_assert((std::is_same<decltype(cosh(Ambiguous())), Ambiguous>::value), "");
244 assert(cosh(0) == 1);
245 }
246
test_exp()247 void test_exp()
248 {
249 static_assert((std::is_same<decltype(exp((float)0)), float>::value), "");
250 static_assert((std::is_same<decltype(exp((bool)0)), double>::value), "");
251 static_assert((std::is_same<decltype(exp((unsigned short)0)), double>::value), "");
252 static_assert((std::is_same<decltype(exp((int)0)), double>::value), "");
253 static_assert((std::is_same<decltype(exp((unsigned int)0)), double>::value), "");
254 static_assert((std::is_same<decltype(exp((long)0)), double>::value), "");
255 static_assert((std::is_same<decltype(exp((unsigned long)0)), double>::value), "");
256 static_assert((std::is_same<decltype(exp((long long)0)), double>::value), "");
257 static_assert((std::is_same<decltype(exp((unsigned long long)0)), double>::value), "");
258 static_assert((std::is_same<decltype(exp((double)0)), double>::value), "");
259 static_assert((std::is_same<decltype(exp((long double)0)), long double>::value), "");
260 static_assert((std::is_same<decltype(expf(0)), float>::value), "");
261 static_assert((std::is_same<decltype(expl(0)), long double>::value), "");
262 static_assert((std::is_same<decltype(exp(Ambiguous())), Ambiguous>::value), "");
263 assert(exp(0) == 1);
264 }
265
test_fabs()266 void test_fabs()
267 {
268 static_assert((std::is_same<decltype(fabs((float)0)), float>::value), "");
269 static_assert((std::is_same<decltype(fabs((bool)0)), double>::value), "");
270 static_assert((std::is_same<decltype(fabs((unsigned short)0)), double>::value), "");
271 static_assert((std::is_same<decltype(fabs((int)0)), double>::value), "");
272 static_assert((std::is_same<decltype(fabs((unsigned int)0)), double>::value), "");
273 static_assert((std::is_same<decltype(fabs((long)0)), double>::value), "");
274 static_assert((std::is_same<decltype(fabs((unsigned long)0)), double>::value), "");
275 static_assert((std::is_same<decltype(fabs((long long)0)), double>::value), "");
276 static_assert((std::is_same<decltype(fabs((unsigned long long)0)), double>::value), "");
277 static_assert((std::is_same<decltype(fabs((double)0)), double>::value), "");
278 static_assert((std::is_same<decltype(fabs((long double)0)), long double>::value), "");
279 static_assert((std::is_same<decltype(fabsf(0.0f)), float>::value), "");
280 static_assert((std::is_same<decltype(fabsl(0.0L)), long double>::value), "");
281 static_assert((std::is_same<decltype(fabs(Ambiguous())), Ambiguous>::value), "");
282 assert(fabs(-1) == 1);
283 }
284
test_floor()285 void test_floor()
286 {
287 static_assert((std::is_same<decltype(floor((float)0)), float>::value), "");
288 static_assert((std::is_same<decltype(floor((bool)0)), double>::value), "");
289 static_assert((std::is_same<decltype(floor((unsigned short)0)), double>::value), "");
290 static_assert((std::is_same<decltype(floor((int)0)), double>::value), "");
291 static_assert((std::is_same<decltype(floor((unsigned int)0)), double>::value), "");
292 static_assert((std::is_same<decltype(floor((long)0)), double>::value), "");
293 static_assert((std::is_same<decltype(floor((unsigned long)0)), double>::value), "");
294 static_assert((std::is_same<decltype(floor((long long)0)), double>::value), "");
295 static_assert((std::is_same<decltype(floor((unsigned long long)0)), double>::value), "");
296 static_assert((std::is_same<decltype(floor((double)0)), double>::value), "");
297 static_assert((std::is_same<decltype(floor((long double)0)), long double>::value), "");
298 static_assert((std::is_same<decltype(floorf(0)), float>::value), "");
299 static_assert((std::is_same<decltype(floorl(0)), long double>::value), "");
300 static_assert((std::is_same<decltype(floor(Ambiguous())), Ambiguous>::value), "");
301 assert(floor(1) == 1);
302 }
303
test_fmod()304 void test_fmod()
305 {
306 static_assert((std::is_same<decltype(fmod((float)0, (float)0)), float>::value), "");
307 static_assert((std::is_same<decltype(fmod((bool)0, (float)0)), double>::value), "");
308 static_assert((std::is_same<decltype(fmod((unsigned short)0, (double)0)), double>::value), "");
309 static_assert((std::is_same<decltype(fmod((int)0, (long double)0)), long double>::value), "");
310 static_assert((std::is_same<decltype(fmod((float)0, (unsigned int)0)), double>::value), "");
311 static_assert((std::is_same<decltype(fmod((double)0, (long)0)), double>::value), "");
312 static_assert((std::is_same<decltype(fmod((long double)0, (unsigned long)0)), long double>::value), "");
313 static_assert((std::is_same<decltype(fmod((int)0, (long long)0)), double>::value), "");
314 static_assert((std::is_same<decltype(fmod((int)0, (unsigned long long)0)), double>::value), "");
315 static_assert((std::is_same<decltype(fmod((double)0, (double)0)), double>::value), "");
316 static_assert((std::is_same<decltype(fmod((long double)0, (long double)0)), long double>::value), "");
317 static_assert((std::is_same<decltype(fmod((float)0, (double)0)), double>::value), "");
318 static_assert((std::is_same<decltype(fmod((float)0, (long double)0)), long double>::value), "");
319 static_assert((std::is_same<decltype(fmod((double)0, (long double)0)), long double>::value), "");
320 static_assert((std::is_same<decltype(fmodf(0,0)), float>::value), "");
321 static_assert((std::is_same<decltype(fmodl(0,0)), long double>::value), "");
322 static_assert((std::is_same<decltype(fmod((int)0, (int)0)), double>::value), "");
323 static_assert((std::is_same<decltype(fmod(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
324 assert(fmod(1.5,1) == .5);
325 }
326
test_frexp()327 void test_frexp()
328 {
329 int ip;
330 static_assert((std::is_same<decltype(frexp((float)0, &ip)), float>::value), "");
331 static_assert((std::is_same<decltype(frexp((bool)0, &ip)), double>::value), "");
332 static_assert((std::is_same<decltype(frexp((unsigned short)0, &ip)), double>::value), "");
333 static_assert((std::is_same<decltype(frexp((int)0, &ip)), double>::value), "");
334 static_assert((std::is_same<decltype(frexp((unsigned int)0, &ip)), double>::value), "");
335 static_assert((std::is_same<decltype(frexp((long)0, &ip)), double>::value), "");
336 static_assert((std::is_same<decltype(frexp((unsigned long)0, &ip)), double>::value), "");
337 static_assert((std::is_same<decltype(frexp((long long)0, &ip)), double>::value), "");
338 static_assert((std::is_same<decltype(frexp((unsigned long long)0, &ip)), double>::value), "");
339 static_assert((std::is_same<decltype(frexp((double)0, &ip)), double>::value), "");
340 static_assert((std::is_same<decltype(frexp((long double)0, &ip)), long double>::value), "");
341 static_assert((std::is_same<decltype(frexpf(0, &ip)), float>::value), "");
342 static_assert((std::is_same<decltype(frexpl(0, &ip)), long double>::value), "");
343 static_assert((std::is_same<decltype(frexp(Ambiguous(), &ip)), Ambiguous>::value), "");
344 assert(frexp(0, &ip) == 0);
345 }
346
test_ldexp()347 void test_ldexp()
348 {
349 int ip = 1;
350 static_assert((std::is_same<decltype(ldexp((float)0, ip)), float>::value), "");
351 static_assert((std::is_same<decltype(ldexp((bool)0, ip)), double>::value), "");
352 static_assert((std::is_same<decltype(ldexp((unsigned short)0, ip)), double>::value), "");
353 static_assert((std::is_same<decltype(ldexp((int)0, ip)), double>::value), "");
354 static_assert((std::is_same<decltype(ldexp((unsigned int)0, ip)), double>::value), "");
355 static_assert((std::is_same<decltype(ldexp((long)0, ip)), double>::value), "");
356 static_assert((std::is_same<decltype(ldexp((unsigned long)0, ip)), double>::value), "");
357 static_assert((std::is_same<decltype(ldexp((long long)0, ip)), double>::value), "");
358 static_assert((std::is_same<decltype(ldexp((unsigned long long)0, ip)), double>::value), "");
359 static_assert((std::is_same<decltype(ldexp((double)0, ip)), double>::value), "");
360 static_assert((std::is_same<decltype(ldexp((long double)0, ip)), long double>::value), "");
361 static_assert((std::is_same<decltype(ldexpf(0, ip)), float>::value), "");
362 static_assert((std::is_same<decltype(ldexpl(0, ip)), long double>::value), "");
363 static_assert((std::is_same<decltype(ldexp(Ambiguous(), ip)), Ambiguous>::value), "");
364 assert(ldexp(1, ip) == 2);
365 }
366
test_log()367 void test_log()
368 {
369 static_assert((std::is_same<decltype(log((float)0)), float>::value), "");
370 static_assert((std::is_same<decltype(log((bool)0)), double>::value), "");
371 static_assert((std::is_same<decltype(log((unsigned short)0)), double>::value), "");
372 static_assert((std::is_same<decltype(log((int)0)), double>::value), "");
373 static_assert((std::is_same<decltype(log((unsigned int)0)), double>::value), "");
374 static_assert((std::is_same<decltype(log((long)0)), double>::value), "");
375 static_assert((std::is_same<decltype(log((unsigned long)0)), double>::value), "");
376 static_assert((std::is_same<decltype(log((long long)0)), double>::value), "");
377 static_assert((std::is_same<decltype(log((unsigned long long)0)), double>::value), "");
378 static_assert((std::is_same<decltype(log((double)0)), double>::value), "");
379 static_assert((std::is_same<decltype(log((long double)0)), long double>::value), "");
380 static_assert((std::is_same<decltype(logf(0)), float>::value), "");
381 static_assert((std::is_same<decltype(logl(0)), long double>::value), "");
382 static_assert((std::is_same<decltype(log(Ambiguous())), Ambiguous>::value), "");
383 assert(log(1) == 0);
384 }
385
test_log10()386 void test_log10()
387 {
388 static_assert((std::is_same<decltype(log10((float)0)), float>::value), "");
389 static_assert((std::is_same<decltype(log10((bool)0)), double>::value), "");
390 static_assert((std::is_same<decltype(log10((unsigned short)0)), double>::value), "");
391 static_assert((std::is_same<decltype(log10((int)0)), double>::value), "");
392 static_assert((std::is_same<decltype(log10((unsigned int)0)), double>::value), "");
393 static_assert((std::is_same<decltype(log10((long)0)), double>::value), "");
394 static_assert((std::is_same<decltype(log10((unsigned long)0)), double>::value), "");
395 static_assert((std::is_same<decltype(log10((long long)0)), double>::value), "");
396 static_assert((std::is_same<decltype(log10((unsigned long long)0)), double>::value), "");
397 static_assert((std::is_same<decltype(log10((double)0)), double>::value), "");
398 static_assert((std::is_same<decltype(log10((long double)0)), long double>::value), "");
399 static_assert((std::is_same<decltype(log10f(0)), float>::value), "");
400 static_assert((std::is_same<decltype(log10l(0)), long double>::value), "");
401 static_assert((std::is_same<decltype(log10(Ambiguous())), Ambiguous>::value), "");
402 assert(log10(1) == 0);
403 }
404
test_modf()405 void test_modf()
406 {
407 static_assert((std::is_same<decltype(modf((float)0, (float*)0)), float>::value), "");
408 static_assert((std::is_same<decltype(modf((double)0, (double*)0)), double>::value), "");
409 static_assert((std::is_same<decltype(modf((long double)0, (long double*)0)), long double>::value), "");
410 static_assert((std::is_same<decltype(modff(0, (float*)0)), float>::value), "");
411 static_assert((std::is_same<decltype(modfl(0, (long double*)0)), long double>::value), "");
412 static_assert((std::is_same<decltype(modf(Ambiguous(), (Ambiguous*)0)), Ambiguous>::value), "");
413 double i;
414 assert(modf(1., &i) == 0);
415 }
416
test_pow()417 void test_pow()
418 {
419 static_assert((std::is_same<decltype(pow((float)0, (float)0)), float>::value), "");
420 static_assert((std::is_same<decltype(pow((bool)0, (float)0)), double>::value), "");
421 static_assert((std::is_same<decltype(pow((unsigned short)0, (double)0)), double>::value), "");
422 static_assert((std::is_same<decltype(pow((int)0, (long double)0)), long double>::value), "");
423 static_assert((std::is_same<decltype(pow((float)0, (unsigned int)0)), double>::value), "");
424 static_assert((std::is_same<decltype(pow((double)0, (long)0)), double>::value), "");
425 static_assert((std::is_same<decltype(pow((long double)0, (unsigned long)0)), long double>::value), "");
426 static_assert((std::is_same<decltype(pow((int)0, (long long)0)), double>::value), "");
427 static_assert((std::is_same<decltype(pow((int)0, (unsigned long long)0)), double>::value), "");
428 static_assert((std::is_same<decltype(pow((double)0, (double)0)), double>::value), "");
429 static_assert((std::is_same<decltype(pow((long double)0, (long double)0)), long double>::value), "");
430 static_assert((std::is_same<decltype(pow((float)0, (double)0)), double>::value), "");
431 static_assert((std::is_same<decltype(pow((float)0, (long double)0)), long double>::value), "");
432 static_assert((std::is_same<decltype(pow((double)0, (long double)0)), long double>::value), "");
433 static_assert((std::is_same<decltype(powf(0,0)), float>::value), "");
434 static_assert((std::is_same<decltype(powl(0,0)), long double>::value), "");
435 static_assert((std::is_same<decltype(pow((int)0, (int)0)), double>::value), "");
436 // static_assert((std::is_same<decltype(pow(Value<int>(), (int)0)), double>::value), "");
437 // static_assert((std::is_same<decltype(pow(Value<long double>(), (float)0)), long double>::value), "");
438 // static_assert((std::is_same<decltype(pow((float) 0, Value<float>())), float>::value), "");
439 static_assert((std::is_same<decltype(pow(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
440 assert(pow(1,1) == 1);
441 // assert(pow(Value<int,1>(), Value<float,1>()) == 1);
442 // assert(pow(1.0f, Value<double,1>()) == 1);
443 // assert(pow(1.0, Value<int,1>()) == 1);
444 // assert(pow(Value<long double,1>(), 1LL) == 1);
445 }
446
test_sin()447 void test_sin()
448 {
449 static_assert((std::is_same<decltype(sin((float)0)), float>::value), "");
450 static_assert((std::is_same<decltype(sin((bool)0)), double>::value), "");
451 static_assert((std::is_same<decltype(sin((unsigned short)0)), double>::value), "");
452 static_assert((std::is_same<decltype(sin((int)0)), double>::value), "");
453 static_assert((std::is_same<decltype(sin((unsigned int)0)), double>::value), "");
454 static_assert((std::is_same<decltype(sin((long)0)), double>::value), "");
455 static_assert((std::is_same<decltype(sin((unsigned long)0)), double>::value), "");
456 static_assert((std::is_same<decltype(sin((long long)0)), double>::value), "");
457 static_assert((std::is_same<decltype(sin((unsigned long long)0)), double>::value), "");
458 static_assert((std::is_same<decltype(sin((double)0)), double>::value), "");
459 static_assert((std::is_same<decltype(sin((long double)0)), long double>::value), "");
460 static_assert((std::is_same<decltype(sinf(0)), float>::value), "");
461 static_assert((std::is_same<decltype(sinl(0)), long double>::value), "");
462 static_assert((std::is_same<decltype(sin(Ambiguous())), Ambiguous>::value), "");
463 assert(sin(0) == 0);
464 }
465
test_sinh()466 void test_sinh()
467 {
468 static_assert((std::is_same<decltype(sinh((float)0)), float>::value), "");
469 static_assert((std::is_same<decltype(sinh((bool)0)), double>::value), "");
470 static_assert((std::is_same<decltype(sinh((unsigned short)0)), double>::value), "");
471 static_assert((std::is_same<decltype(sinh((int)0)), double>::value), "");
472 static_assert((std::is_same<decltype(sinh((unsigned int)0)), double>::value), "");
473 static_assert((std::is_same<decltype(sinh((long)0)), double>::value), "");
474 static_assert((std::is_same<decltype(sinh((unsigned long)0)), double>::value), "");
475 static_assert((std::is_same<decltype(sinh((long long)0)), double>::value), "");
476 static_assert((std::is_same<decltype(sinh((unsigned long long)0)), double>::value), "");
477 static_assert((std::is_same<decltype(sinh((double)0)), double>::value), "");
478 static_assert((std::is_same<decltype(sinh((long double)0)), long double>::value), "");
479 static_assert((std::is_same<decltype(sinhf(0)), float>::value), "");
480 static_assert((std::is_same<decltype(sinhl(0)), long double>::value), "");
481 static_assert((std::is_same<decltype(sinh(Ambiguous())), Ambiguous>::value), "");
482 assert(sinh(0) == 0);
483 }
484
test_sqrt()485 void test_sqrt()
486 {
487 static_assert((std::is_same<decltype(sqrt((float)0)), float>::value), "");
488 static_assert((std::is_same<decltype(sqrt((bool)0)), double>::value), "");
489 static_assert((std::is_same<decltype(sqrt((unsigned short)0)), double>::value), "");
490 static_assert((std::is_same<decltype(sqrt((int)0)), double>::value), "");
491 static_assert((std::is_same<decltype(sqrt((unsigned int)0)), double>::value), "");
492 static_assert((std::is_same<decltype(sqrt((long)0)), double>::value), "");
493 static_assert((std::is_same<decltype(sqrt((unsigned long)0)), double>::value), "");
494 static_assert((std::is_same<decltype(sqrt((long long)0)), double>::value), "");
495 static_assert((std::is_same<decltype(sqrt((unsigned long long)0)), double>::value), "");
496 static_assert((std::is_same<decltype(sqrt((double)0)), double>::value), "");
497 static_assert((std::is_same<decltype(sqrt((long double)0)), long double>::value), "");
498 static_assert((std::is_same<decltype(sqrtf(0)), float>::value), "");
499 static_assert((std::is_same<decltype(sqrtl(0)), long double>::value), "");
500 static_assert((std::is_same<decltype(sqrt(Ambiguous())), Ambiguous>::value), "");
501 assert(sqrt(4) == 2);
502 }
503
test_tan()504 void test_tan()
505 {
506 static_assert((std::is_same<decltype(tan((float)0)), float>::value), "");
507 static_assert((std::is_same<decltype(tan((bool)0)), double>::value), "");
508 static_assert((std::is_same<decltype(tan((unsigned short)0)), double>::value), "");
509 static_assert((std::is_same<decltype(tan((int)0)), double>::value), "");
510 static_assert((std::is_same<decltype(tan((unsigned int)0)), double>::value), "");
511 static_assert((std::is_same<decltype(tan((long)0)), double>::value), "");
512 static_assert((std::is_same<decltype(tan((unsigned long)0)), double>::value), "");
513 static_assert((std::is_same<decltype(tan((long long)0)), double>::value), "");
514 static_assert((std::is_same<decltype(tan((unsigned long long)0)), double>::value), "");
515 static_assert((std::is_same<decltype(tan((double)0)), double>::value), "");
516 static_assert((std::is_same<decltype(tan((long double)0)), long double>::value), "");
517 static_assert((std::is_same<decltype(tanf(0)), float>::value), "");
518 static_assert((std::is_same<decltype(tanl(0)), long double>::value), "");
519 static_assert((std::is_same<decltype(tan(Ambiguous())), Ambiguous>::value), "");
520 assert(tan(0) == 0);
521 }
522
test_tanh()523 void test_tanh()
524 {
525 static_assert((std::is_same<decltype(tanh((float)0)), float>::value), "");
526 static_assert((std::is_same<decltype(tanh((bool)0)), double>::value), "");
527 static_assert((std::is_same<decltype(tanh((unsigned short)0)), double>::value), "");
528 static_assert((std::is_same<decltype(tanh((int)0)), double>::value), "");
529 static_assert((std::is_same<decltype(tanh((unsigned int)0)), double>::value), "");
530 static_assert((std::is_same<decltype(tanh((long)0)), double>::value), "");
531 static_assert((std::is_same<decltype(tanh((unsigned long)0)), double>::value), "");
532 static_assert((std::is_same<decltype(tanh((long long)0)), double>::value), "");
533 static_assert((std::is_same<decltype(tanh((unsigned long long)0)), double>::value), "");
534 static_assert((std::is_same<decltype(tanh((double)0)), double>::value), "");
535 static_assert((std::is_same<decltype(tanh((long double)0)), long double>::value), "");
536 static_assert((std::is_same<decltype(tanhf(0)), float>::value), "");
537 static_assert((std::is_same<decltype(tanhl(0)), long double>::value), "");
538 static_assert((std::is_same<decltype(tanh(Ambiguous())), Ambiguous>::value), "");
539 assert(tanh(0) == 0);
540 }
541
test_signbit()542 void test_signbit()
543 {
544 #ifdef signbit
545 #error signbit defined
546 #endif
547 static_assert((std::is_same<decltype(signbit((float)0)), bool>::value), "");
548 static_assert((std::is_same<decltype(signbit((double)0)), bool>::value), "");
549 static_assert((std::is_same<decltype(signbit(0)), bool>::value), "");
550 static_assert((std::is_same<decltype(signbit((long double)0)), bool>::value), "");
551 static_assert((std::is_same<decltype(signbit(Ambiguous())), Ambiguous>::value), "");
552 assert(signbit(-1.0) == true);
553 }
554
test_fpclassify()555 void test_fpclassify()
556 {
557 #ifdef fpclassify
558 #error fpclassify defined
559 #endif
560 static_assert((std::is_same<decltype(fpclassify((float)0)), int>::value), "");
561 static_assert((std::is_same<decltype(fpclassify((double)0)), int>::value), "");
562 static_assert((std::is_same<decltype(fpclassify(0)), int>::value), "");
563 static_assert((std::is_same<decltype(fpclassify((long double)0)), int>::value), "");
564 static_assert((std::is_same<decltype(fpclassify(Ambiguous())), Ambiguous>::value), "");
565 assert(fpclassify(-1.0) == FP_NORMAL);
566 }
567
test_isfinite()568 void test_isfinite()
569 {
570 #ifdef isfinite
571 #error isfinite defined
572 #endif
573 static_assert((std::is_same<decltype(isfinite((float)0)), bool>::value), "");
574 static_assert((std::is_same<decltype(isfinite((double)0)), bool>::value), "");
575 static_assert((std::is_same<decltype(isfinite(0)), bool>::value), "");
576 static_assert((std::is_same<decltype(isfinite((long double)0)), bool>::value), "");
577 static_assert((std::is_same<decltype(isfinite(Ambiguous())), Ambiguous>::value), "");
578 assert(isfinite(-1.0) == true);
579 }
580
test_isnormal()581 void test_isnormal()
582 {
583 #ifdef isnormal
584 #error isnormal defined
585 #endif
586 static_assert((std::is_same<decltype(isnormal((float)0)), bool>::value), "");
587 static_assert((std::is_same<decltype(isnormal((double)0)), bool>::value), "");
588 static_assert((std::is_same<decltype(isnormal(0)), bool>::value), "");
589 static_assert((std::is_same<decltype(isnormal((long double)0)), bool>::value), "");
590 static_assert((std::is_same<decltype(isnormal(Ambiguous())), Ambiguous>::value), "");
591 assert(isnormal(-1.0) == true);
592 }
593
test_isgreater()594 void test_isgreater()
595 {
596 #ifdef isgreater
597 #error isgreater defined
598 #endif
599 static_assert((std::is_same<decltype(isgreater((float)0, (float)0)), bool>::value), "");
600 static_assert((std::is_same<decltype(isgreater((float)0, (double)0)), bool>::value), "");
601 static_assert((std::is_same<decltype(isgreater((float)0, (long double)0)), bool>::value), "");
602 static_assert((std::is_same<decltype(isgreater((double)0, (float)0)), bool>::value), "");
603 static_assert((std::is_same<decltype(isgreater((double)0, (double)0)), bool>::value), "");
604 static_assert((std::is_same<decltype(isgreater(0, (double)0)), bool>::value), "");
605 static_assert((std::is_same<decltype(isgreater((double)0, (long double)0)), bool>::value), "");
606 static_assert((std::is_same<decltype(isgreater((long double)0, (float)0)), bool>::value), "");
607 static_assert((std::is_same<decltype(isgreater((long double)0, (double)0)), bool>::value), "");
608 static_assert((std::is_same<decltype(isgreater((long double)0, (long double)0)), bool>::value), "");
609 static_assert((std::is_same<decltype(isgreater(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
610 assert(isgreater(-1.0, 0.F) == false);
611 }
612
test_isgreaterequal()613 void test_isgreaterequal()
614 {
615 #ifdef isgreaterequal
616 #error isgreaterequal defined
617 #endif
618 static_assert((std::is_same<decltype(isgreaterequal((float)0, (float)0)), bool>::value), "");
619 static_assert((std::is_same<decltype(isgreaterequal((float)0, (double)0)), bool>::value), "");
620 static_assert((std::is_same<decltype(isgreaterequal((float)0, (long double)0)), bool>::value), "");
621 static_assert((std::is_same<decltype(isgreaterequal((double)0, (float)0)), bool>::value), "");
622 static_assert((std::is_same<decltype(isgreaterequal((double)0, (double)0)), bool>::value), "");
623 static_assert((std::is_same<decltype(isgreaterequal(0, (double)0)), bool>::value), "");
624 static_assert((std::is_same<decltype(isgreaterequal((double)0, (long double)0)), bool>::value), "");
625 static_assert((std::is_same<decltype(isgreaterequal((long double)0, (float)0)), bool>::value), "");
626 static_assert((std::is_same<decltype(isgreaterequal((long double)0, (double)0)), bool>::value), "");
627 static_assert((std::is_same<decltype(isgreaterequal((long double)0, (long double)0)), bool>::value), "");
628 static_assert((std::is_same<decltype(isgreaterequal(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
629 assert(isgreaterequal(-1.0, 0.F) == false);
630 }
631
test_isinf()632 void test_isinf()
633 {
634 #ifdef isinf
635 #error isinf defined
636 #endif
637 static_assert((std::is_same<decltype(isinf((float)0)), bool>::value), "");
638
639 typedef decltype(isinf((double)0)) DoubleRetType;
640 #ifndef __linux__
641 static_assert((std::is_same<DoubleRetType, bool>::value), "");
642 #else
643 // GLIBC < 2.26 defines 'isinf(double)' with a return type of 'int' in
644 // all C++ dialects. The test should tolerate this.
645 // See: https://sourceware.org/bugzilla/show_bug.cgi?id=19439
646 static_assert((std::is_same<DoubleRetType, bool>::value
647 || std::is_same<DoubleRetType, int>::value), "");
648 #endif
649
650 static_assert((std::is_same<decltype(isinf(0)), bool>::value), "");
651 static_assert((std::is_same<decltype(isinf((long double)0)), bool>::value), "");
652 assert(isinf(-1.0) == false);
653 }
654
test_isless()655 void test_isless()
656 {
657 #ifdef isless
658 #error isless defined
659 #endif
660 static_assert((std::is_same<decltype(isless((float)0, (float)0)), bool>::value), "");
661 static_assert((std::is_same<decltype(isless((float)0, (double)0)), bool>::value), "");
662 static_assert((std::is_same<decltype(isless((float)0, (long double)0)), bool>::value), "");
663 static_assert((std::is_same<decltype(isless((double)0, (float)0)), bool>::value), "");
664 static_assert((std::is_same<decltype(isless((double)0, (double)0)), bool>::value), "");
665 static_assert((std::is_same<decltype(isless(0, (double)0)), bool>::value), "");
666 static_assert((std::is_same<decltype(isless((double)0, (long double)0)), bool>::value), "");
667 static_assert((std::is_same<decltype(isless((long double)0, (float)0)), bool>::value), "");
668 static_assert((std::is_same<decltype(isless((long double)0, (double)0)), bool>::value), "");
669 static_assert((std::is_same<decltype(isless((long double)0, (long double)0)), bool>::value), "");
670 static_assert((std::is_same<decltype(isless(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
671 assert(isless(-1.0, 0.F) == true);
672 }
673
test_islessequal()674 void test_islessequal()
675 {
676 #ifdef islessequal
677 #error islessequal defined
678 #endif
679 static_assert((std::is_same<decltype(islessequal((float)0, (float)0)), bool>::value), "");
680 static_assert((std::is_same<decltype(islessequal((float)0, (double)0)), bool>::value), "");
681 static_assert((std::is_same<decltype(islessequal((float)0, (long double)0)), bool>::value), "");
682 static_assert((std::is_same<decltype(islessequal((double)0, (float)0)), bool>::value), "");
683 static_assert((std::is_same<decltype(islessequal((double)0, (double)0)), bool>::value), "");
684 static_assert((std::is_same<decltype(islessequal(0, (double)0)), bool>::value), "");
685 static_assert((std::is_same<decltype(islessequal((double)0, (long double)0)), bool>::value), "");
686 static_assert((std::is_same<decltype(islessequal((long double)0, (float)0)), bool>::value), "");
687 static_assert((std::is_same<decltype(islessequal((long double)0, (double)0)), bool>::value), "");
688 static_assert((std::is_same<decltype(islessequal((long double)0, (long double)0)), bool>::value), "");
689 static_assert((std::is_same<decltype(islessequal(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
690 assert(islessequal(-1.0, 0.F) == true);
691 }
692
test_islessgreater()693 void test_islessgreater()
694 {
695 #ifdef islessgreater
696 #error islessgreater defined
697 #endif
698 static_assert((std::is_same<decltype(islessgreater((float)0, (float)0)), bool>::value), "");
699 static_assert((std::is_same<decltype(islessgreater((float)0, (double)0)), bool>::value), "");
700 static_assert((std::is_same<decltype(islessgreater((float)0, (long double)0)), bool>::value), "");
701 static_assert((std::is_same<decltype(islessgreater((double)0, (float)0)), bool>::value), "");
702 static_assert((std::is_same<decltype(islessgreater((double)0, (double)0)), bool>::value), "");
703 static_assert((std::is_same<decltype(islessgreater(0, (double)0)), bool>::value), "");
704 static_assert((std::is_same<decltype(islessgreater((double)0, (long double)0)), bool>::value), "");
705 static_assert((std::is_same<decltype(islessgreater((long double)0, (float)0)), bool>::value), "");
706 static_assert((std::is_same<decltype(islessgreater((long double)0, (double)0)), bool>::value), "");
707 static_assert((std::is_same<decltype(islessgreater((long double)0, (long double)0)), bool>::value), "");
708 static_assert((std::is_same<decltype(islessgreater(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
709 assert(islessgreater(-1.0, 0.F) == true);
710 }
711
test_isnan()712 void test_isnan()
713 {
714 #ifdef isnan
715 #error isnan defined
716 #endif
717 static_assert((std::is_same<decltype(isnan((float)0)), bool>::value), "");
718
719 typedef decltype(isnan((double)0)) DoubleRetType;
720 #ifndef __linux__
721 static_assert((std::is_same<DoubleRetType, bool>::value), "");
722 #else
723 // GLIBC < 2.26 defines 'isnan(double)' with a return type of 'int' in
724 // all C++ dialects. The test should tolerate this.
725 // See: https://sourceware.org/bugzilla/show_bug.cgi?id=19439
726 static_assert((std::is_same<DoubleRetType, bool>::value
727 || std::is_same<DoubleRetType, int>::value), "");
728 #endif
729
730 static_assert((std::is_same<decltype(isnan(0)), bool>::value), "");
731 static_assert((std::is_same<decltype(isnan((long double)0)), bool>::value), "");
732 assert(isnan(-1.0) == false);
733 }
734
test_isunordered()735 void test_isunordered()
736 {
737 #ifdef isunordered
738 #error isunordered defined
739 #endif
740 static_assert((std::is_same<decltype(isunordered((float)0, (float)0)), bool>::value), "");
741 static_assert((std::is_same<decltype(isunordered((float)0, (double)0)), bool>::value), "");
742 static_assert((std::is_same<decltype(isunordered((float)0, (long double)0)), bool>::value), "");
743 static_assert((std::is_same<decltype(isunordered((double)0, (float)0)), bool>::value), "");
744 static_assert((std::is_same<decltype(isunordered((double)0, (double)0)), bool>::value), "");
745 static_assert((std::is_same<decltype(isunordered(0, (double)0)), bool>::value), "");
746 static_assert((std::is_same<decltype(isunordered((double)0, (long double)0)), bool>::value), "");
747 static_assert((std::is_same<decltype(isunordered((long double)0, (float)0)), bool>::value), "");
748 static_assert((std::is_same<decltype(isunordered((long double)0, (double)0)), bool>::value), "");
749 static_assert((std::is_same<decltype(isunordered((long double)0, (long double)0)), bool>::value), "");
750 static_assert((std::is_same<decltype(isunordered(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
751 assert(isunordered(-1.0, 0.F) == false);
752 }
753
test_acosh()754 void test_acosh()
755 {
756 static_assert((std::is_same<decltype(acosh((float)0)), float>::value), "");
757 static_assert((std::is_same<decltype(acosh((bool)0)), double>::value), "");
758 static_assert((std::is_same<decltype(acosh((unsigned short)0)), double>::value), "");
759 static_assert((std::is_same<decltype(acosh((int)0)), double>::value), "");
760 static_assert((std::is_same<decltype(acosh((unsigned int)0)), double>::value), "");
761 static_assert((std::is_same<decltype(acosh((long)0)), double>::value), "");
762 static_assert((std::is_same<decltype(acosh((unsigned long)0)), double>::value), "");
763 static_assert((std::is_same<decltype(acosh((long long)0)), double>::value), "");
764 static_assert((std::is_same<decltype(acosh((unsigned long long)0)), double>::value), "");
765 static_assert((std::is_same<decltype(acosh((double)0)), double>::value), "");
766 static_assert((std::is_same<decltype(acosh((long double)0)), long double>::value), "");
767 static_assert((std::is_same<decltype(acoshf(0)), float>::value), "");
768 static_assert((std::is_same<decltype(acoshl(0)), long double>::value), "");
769 static_assert((std::is_same<decltype(acosh(Ambiguous())), Ambiguous>::value), "");
770 assert(acosh(1) == 0);
771 }
772
test_asinh()773 void test_asinh()
774 {
775 static_assert((std::is_same<decltype(asinh((float)0)), float>::value), "");
776 static_assert((std::is_same<decltype(asinh((bool)0)), double>::value), "");
777 static_assert((std::is_same<decltype(asinh((unsigned short)0)), double>::value), "");
778 static_assert((std::is_same<decltype(asinh((int)0)), double>::value), "");
779 static_assert((std::is_same<decltype(asinh((unsigned int)0)), double>::value), "");
780 static_assert((std::is_same<decltype(asinh((long)0)), double>::value), "");
781 static_assert((std::is_same<decltype(asinh((unsigned long)0)), double>::value), "");
782 static_assert((std::is_same<decltype(asinh((long long)0)), double>::value), "");
783 static_assert((std::is_same<decltype(asinh((unsigned long long)0)), double>::value), "");
784 static_assert((std::is_same<decltype(asinh((double)0)), double>::value), "");
785 static_assert((std::is_same<decltype(asinh((long double)0)), long double>::value), "");
786 static_assert((std::is_same<decltype(asinhf(0)), float>::value), "");
787 static_assert((std::is_same<decltype(asinhl(0)), long double>::value), "");
788 static_assert((std::is_same<decltype(asinh(Ambiguous())), Ambiguous>::value), "");
789 assert(asinh(0) == 0);
790 }
791
test_atanh()792 void test_atanh()
793 {
794 static_assert((std::is_same<decltype(atanh((float)0)), float>::value), "");
795 static_assert((std::is_same<decltype(atanh((bool)0)), double>::value), "");
796 static_assert((std::is_same<decltype(atanh((unsigned short)0)), double>::value), "");
797 static_assert((std::is_same<decltype(atanh((int)0)), double>::value), "");
798 static_assert((std::is_same<decltype(atanh((unsigned int)0)), double>::value), "");
799 static_assert((std::is_same<decltype(atanh((long)0)), double>::value), "");
800 static_assert((std::is_same<decltype(atanh((unsigned long)0)), double>::value), "");
801 static_assert((std::is_same<decltype(atanh((long long)0)), double>::value), "");
802 static_assert((std::is_same<decltype(atanh((unsigned long long)0)), double>::value), "");
803 static_assert((std::is_same<decltype(atanh((double)0)), double>::value), "");
804 static_assert((std::is_same<decltype(atanh((long double)0)), long double>::value), "");
805 static_assert((std::is_same<decltype(atanhf(0)), float>::value), "");
806 static_assert((std::is_same<decltype(atanhl(0)), long double>::value), "");
807 static_assert((std::is_same<decltype(atanh(Ambiguous())), Ambiguous>::value), "");
808 assert(atanh(0) == 0);
809 }
810
test_cbrt()811 void test_cbrt() {
812 static_assert((std::is_same<decltype(cbrt((float) 0)), float>::value), "");
813 static_assert((std::is_same<decltype(cbrt((bool) 0)), double>::value), "");
814 static_assert((std::is_same<decltype(cbrt((unsigned short) 0)),
815 double>::value), "");
816 static_assert((std::is_same<decltype(cbrt((int) 0)), double>::value), "");
817 static_assert((std::is_same<decltype(cbrt((unsigned int) 0)),
818 double>::value), "");
819 static_assert((std::is_same<decltype(cbrt((long) 0)), double>::value), "");
820 static_assert((std::is_same<decltype(cbrt((unsigned long) 0)),
821 double>::value), "");
822 static_assert((std::is_same<decltype(cbrt((long long) 0)), double>::value),
823 "");
824 static_assert((std::is_same<decltype(cbrt((unsigned long long) 0)),
825 double>::value), "");
826 static_assert((std::is_same<decltype(cbrt((double) 0)), double>::value),
827 "");
828 static_assert((std::is_same<decltype(cbrt((long double) 0)),
829 long double>::value), "");
830 static_assert((std::is_same<decltype(cbrtf(0)), float>::value), "");
831 static_assert((std::is_same<decltype(cbrtl(0)), long double>::value), "");
832 static_assert((std::is_same<decltype(cbrt(Ambiguous())), Ambiguous>::value),
833 "");
834 assert(truncate_fp(cbrt(1)) == 1);
835
836 }
837
test_copysign()838 void test_copysign()
839 {
840 static_assert((std::is_same<decltype(copysign((float)0, (float)0)), float>::value), "");
841 static_assert((std::is_same<decltype(copysign((bool)0, (float)0)), double>::value), "");
842 static_assert((std::is_same<decltype(copysign((unsigned short)0, (double)0)), double>::value), "");
843 static_assert((std::is_same<decltype(copysign((int)0, (long double)0)), long double>::value), "");
844 static_assert((std::is_same<decltype(copysign((float)0, (unsigned int)0)), double>::value), "");
845 static_assert((std::is_same<decltype(copysign((double)0, (long)0)), double>::value), "");
846 static_assert((std::is_same<decltype(copysign((long double)0, (unsigned long)0)), long double>::value), "");
847 static_assert((std::is_same<decltype(copysign((int)0, (long long)0)), double>::value), "");
848 static_assert((std::is_same<decltype(copysign((int)0, (unsigned long long)0)), double>::value), "");
849 static_assert((std::is_same<decltype(copysign((double)0, (double)0)), double>::value), "");
850 static_assert((std::is_same<decltype(copysign((long double)0, (long double)0)), long double>::value), "");
851 static_assert((std::is_same<decltype(copysign((float)0, (double)0)), double>::value), "");
852 static_assert((std::is_same<decltype(copysign((float)0, (long double)0)), long double>::value), "");
853 static_assert((std::is_same<decltype(copysign((double)0, (long double)0)), long double>::value), "");
854 static_assert((std::is_same<decltype(copysignf(0,0)), float>::value), "");
855 static_assert((std::is_same<decltype(copysignl(0,0)), long double>::value), "");
856 static_assert((std::is_same<decltype(copysign((int)0, (int)0)), double>::value), "");
857 static_assert((std::is_same<decltype(copysign(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
858 assert(copysign(1,1) == 1);
859 }
860
test_erf()861 void test_erf()
862 {
863 static_assert((std::is_same<decltype(erf((float)0)), float>::value), "");
864 static_assert((std::is_same<decltype(erf((bool)0)), double>::value), "");
865 static_assert((std::is_same<decltype(erf((unsigned short)0)), double>::value), "");
866 static_assert((std::is_same<decltype(erf((int)0)), double>::value), "");
867 static_assert((std::is_same<decltype(erf((unsigned int)0)), double>::value), "");
868 static_assert((std::is_same<decltype(erf((long)0)), double>::value), "");
869 static_assert((std::is_same<decltype(erf((unsigned long)0)), double>::value), "");
870 static_assert((std::is_same<decltype(erf((long long)0)), double>::value), "");
871 static_assert((std::is_same<decltype(erf((unsigned long long)0)), double>::value), "");
872 static_assert((std::is_same<decltype(erf((double)0)), double>::value), "");
873 static_assert((std::is_same<decltype(erf((long double)0)), long double>::value), "");
874 static_assert((std::is_same<decltype(erff(0)), float>::value), "");
875 static_assert((std::is_same<decltype(erfl(0)), long double>::value), "");
876 static_assert((std::is_same<decltype(erf(Ambiguous())), Ambiguous>::value), "");
877 assert(erf(0) == 0);
878 }
879
test_erfc()880 void test_erfc()
881 {
882 static_assert((std::is_same<decltype(erfc((float)0)), float>::value), "");
883 static_assert((std::is_same<decltype(erfc((bool)0)), double>::value), "");
884 static_assert((std::is_same<decltype(erfc((unsigned short)0)), double>::value), "");
885 static_assert((std::is_same<decltype(erfc((int)0)), double>::value), "");
886 static_assert((std::is_same<decltype(erfc((unsigned int)0)), double>::value), "");
887 static_assert((std::is_same<decltype(erfc((long)0)), double>::value), "");
888 static_assert((std::is_same<decltype(erfc((unsigned long)0)), double>::value), "");
889 static_assert((std::is_same<decltype(erfc((long long)0)), double>::value), "");
890 static_assert((std::is_same<decltype(erfc((unsigned long long)0)), double>::value), "");
891 static_assert((std::is_same<decltype(erfc((double)0)), double>::value), "");
892 static_assert((std::is_same<decltype(erfc((long double)0)), long double>::value), "");
893 static_assert((std::is_same<decltype(erfcf(0)), float>::value), "");
894 static_assert((std::is_same<decltype(erfcl(0)), long double>::value), "");
895 static_assert((std::is_same<decltype(erfc(Ambiguous())), Ambiguous>::value), "");
896 assert(erfc(0) == 1);
897 }
898
test_exp2()899 void test_exp2()
900 {
901 static_assert((std::is_same<decltype(exp2((float)0)), float>::value), "");
902 static_assert((std::is_same<decltype(exp2((bool)0)), double>::value), "");
903 static_assert((std::is_same<decltype(exp2((unsigned short)0)), double>::value), "");
904 static_assert((std::is_same<decltype(exp2((int)0)), double>::value), "");
905 static_assert((std::is_same<decltype(exp2((unsigned int)0)), double>::value), "");
906 static_assert((std::is_same<decltype(exp2((long)0)), double>::value), "");
907 static_assert((std::is_same<decltype(exp2((unsigned long)0)), double>::value), "");
908 static_assert((std::is_same<decltype(exp2((long long)0)), double>::value), "");
909 static_assert((std::is_same<decltype(exp2((unsigned long long)0)), double>::value), "");
910 static_assert((std::is_same<decltype(exp2((double)0)), double>::value), "");
911 static_assert((std::is_same<decltype(exp2((long double)0)), long double>::value), "");
912 static_assert((std::is_same<decltype(exp2f(0)), float>::value), "");
913 static_assert((std::is_same<decltype(exp2l(0)), long double>::value), "");
914 static_assert((std::is_same<decltype(exp2(Ambiguous())), Ambiguous>::value), "");
915 assert(exp2(1) == 2);
916 }
917
test_expm1()918 void test_expm1()
919 {
920 static_assert((std::is_same<decltype(expm1((float)0)), float>::value), "");
921 static_assert((std::is_same<decltype(expm1((bool)0)), double>::value), "");
922 static_assert((std::is_same<decltype(expm1((unsigned short)0)), double>::value), "");
923 static_assert((std::is_same<decltype(expm1((int)0)), double>::value), "");
924 static_assert((std::is_same<decltype(expm1((unsigned int)0)), double>::value), "");
925 static_assert((std::is_same<decltype(expm1((long)0)), double>::value), "");
926 static_assert((std::is_same<decltype(expm1((unsigned long)0)), double>::value), "");
927 static_assert((std::is_same<decltype(expm1((long long)0)), double>::value), "");
928 static_assert((std::is_same<decltype(expm1((unsigned long long)0)), double>::value), "");
929 static_assert((std::is_same<decltype(expm1((double)0)), double>::value), "");
930 static_assert((std::is_same<decltype(expm1((long double)0)), long double>::value), "");
931 static_assert((std::is_same<decltype(expm1f(0)), float>::value), "");
932 static_assert((std::is_same<decltype(expm1l(0)), long double>::value), "");
933 static_assert((std::is_same<decltype(expm1(Ambiguous())), Ambiguous>::value), "");
934 assert(expm1(0) == 0);
935 }
936
test_fdim()937 void test_fdim()
938 {
939 static_assert((std::is_same<decltype(fdim((float)0, (float)0)), float>::value), "");
940 static_assert((std::is_same<decltype(fdim((bool)0, (float)0)), double>::value), "");
941 static_assert((std::is_same<decltype(fdim((unsigned short)0, (double)0)), double>::value), "");
942 static_assert((std::is_same<decltype(fdim((int)0, (long double)0)), long double>::value), "");
943 static_assert((std::is_same<decltype(fdim((float)0, (unsigned int)0)), double>::value), "");
944 static_assert((std::is_same<decltype(fdim((double)0, (long)0)), double>::value), "");
945 static_assert((std::is_same<decltype(fdim((long double)0, (unsigned long)0)), long double>::value), "");
946 static_assert((std::is_same<decltype(fdim((int)0, (long long)0)), double>::value), "");
947 static_assert((std::is_same<decltype(fdim((int)0, (unsigned long long)0)), double>::value), "");
948 static_assert((std::is_same<decltype(fdim((double)0, (double)0)), double>::value), "");
949 static_assert((std::is_same<decltype(fdim((long double)0, (long double)0)), long double>::value), "");
950 static_assert((std::is_same<decltype(fdim((float)0, (double)0)), double>::value), "");
951 static_assert((std::is_same<decltype(fdim((float)0, (long double)0)), long double>::value), "");
952 static_assert((std::is_same<decltype(fdim((double)0, (long double)0)), long double>::value), "");
953 static_assert((std::is_same<decltype(fdimf(0,0)), float>::value), "");
954 static_assert((std::is_same<decltype(fdiml(0,0)), long double>::value), "");
955 static_assert((std::is_same<decltype(fdim((int)0, (int)0)), double>::value), "");
956 static_assert((std::is_same<decltype(fdim(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
957 assert(fdim(1,0) == 1);
958 }
959
test_fma()960 void test_fma()
961 {
962 static_assert((std::is_same<decltype(fma((bool)0, (float)0, (float)0)), double>::value), "");
963 static_assert((std::is_same<decltype(fma((char)0, (float)0, (float)0)), double>::value), "");
964 static_assert((std::is_same<decltype(fma((unsigned)0, (float)0, (float)0)), double>::value), "");
965 static_assert((std::is_same<decltype(fma((float)0, (int)0, (float)0)), double>::value), "");
966 static_assert((std::is_same<decltype(fma((float)0, (long)0, (float)0)), double>::value), "");
967 static_assert((std::is_same<decltype(fma((float)0, (float)0, (unsigned long long)0)), double>::value), "");
968 static_assert((std::is_same<decltype(fma((float)0, (float)0, (double)0)), double>::value), "");
969 static_assert((std::is_same<decltype(fma((float)0, (float)0, (long double)0)), long double>::value), "");
970 static_assert((std::is_same<decltype(fma((float)0, (float)0, (float)0)), float>::value), "");
971
972 static_assert((std::is_same<decltype(fma((bool)0, (double)0, (double)0)), double>::value), "");
973 static_assert((std::is_same<decltype(fma((char)0, (double)0, (double)0)), double>::value), "");
974 static_assert((std::is_same<decltype(fma((unsigned)0, (double)0, (double)0)), double>::value), "");
975 static_assert((std::is_same<decltype(fma((double)0, (int)0, (double)0)), double>::value), "");
976 static_assert((std::is_same<decltype(fma((double)0, (long)0, (double)0)), double>::value), "");
977 static_assert((std::is_same<decltype(fma((double)0, (double)0, (unsigned long long)0)), double>::value), "");
978 static_assert((std::is_same<decltype(fma((double)0, (double)0, (float)0)), double>::value), "");
979 static_assert((std::is_same<decltype(fma((double)0, (double)0, (long double)0)), long double>::value), "");
980 static_assert((std::is_same<decltype(fma((double)0, (double)0, (double)0)), double>::value), "");
981
982 static_assert((std::is_same<decltype(fma((bool)0, (long double)0, (long double)0)), long double>::value), "");
983 static_assert((std::is_same<decltype(fma((char)0, (long double)0, (long double)0)), long double>::value), "");
984 static_assert((std::is_same<decltype(fma((unsigned)0, (long double)0, (long double)0)), long double>::value), "");
985 static_assert((std::is_same<decltype(fma((long double)0, (int)0, (long double)0)), long double>::value), "");
986 static_assert((std::is_same<decltype(fma((long double)0, (long)0, (long double)0)), long double>::value), "");
987 static_assert((std::is_same<decltype(fma((long double)0, (long double)0, (unsigned long long)0)), long double>::value), "");
988 static_assert((std::is_same<decltype(fma((long double)0, (long double)0, (float)0)), long double>::value), "");
989 static_assert((std::is_same<decltype(fma((double)0, (long double)0, (long double)0)), long double>::value), "");
990 static_assert((std::is_same<decltype(fma((long double)0, (long double)0, (long double)0)), long double>::value), "");
991
992 static_assert((std::is_same<decltype(fmaf(0,0,0)), float>::value), "");
993 static_assert((std::is_same<decltype(fmal(0,0,0)), long double>::value), "");
994 static_assert((std::is_same<decltype(fma(Ambiguous(), Ambiguous(), Ambiguous())), Ambiguous>::value), "");
995 assert(fma(1,1,1) == 2);
996 }
997
test_fmax()998 void test_fmax()
999 {
1000 static_assert((std::is_same<decltype(fmax((float)0, (float)0)), float>::value), "");
1001 static_assert((std::is_same<decltype(fmax((bool)0, (float)0)), double>::value), "");
1002 static_assert((std::is_same<decltype(fmax((unsigned short)0, (double)0)), double>::value), "");
1003 static_assert((std::is_same<decltype(fmax((int)0, (long double)0)), long double>::value), "");
1004 static_assert((std::is_same<decltype(fmax((float)0, (unsigned int)0)), double>::value), "");
1005 static_assert((std::is_same<decltype(fmax((double)0, (long)0)), double>::value), "");
1006 static_assert((std::is_same<decltype(fmax((long double)0, (unsigned long)0)), long double>::value), "");
1007 static_assert((std::is_same<decltype(fmax((int)0, (long long)0)), double>::value), "");
1008 static_assert((std::is_same<decltype(fmax((int)0, (unsigned long long)0)), double>::value), "");
1009 static_assert((std::is_same<decltype(fmax((double)0, (double)0)), double>::value), "");
1010 static_assert((std::is_same<decltype(fmax((long double)0, (long double)0)), long double>::value), "");
1011 static_assert((std::is_same<decltype(fmax((float)0, (double)0)), double>::value), "");
1012 static_assert((std::is_same<decltype(fmax((float)0, (long double)0)), long double>::value), "");
1013 static_assert((std::is_same<decltype(fmax((double)0, (long double)0)), long double>::value), "");
1014 static_assert((std::is_same<decltype(fmaxf(0,0)), float>::value), "");
1015 static_assert((std::is_same<decltype(fmaxl(0,0)), long double>::value), "");
1016 static_assert((std::is_same<decltype(fmax((int)0, (int)0)), double>::value), "");
1017 static_assert((std::is_same<decltype(fmax(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1018 assert(fmax(1,0) == 1);
1019 }
1020
test_fmin()1021 void test_fmin()
1022 {
1023 static_assert((std::is_same<decltype(fmin((float)0, (float)0)), float>::value), "");
1024 static_assert((std::is_same<decltype(fmin((bool)0, (float)0)), double>::value), "");
1025 static_assert((std::is_same<decltype(fmin((unsigned short)0, (double)0)), double>::value), "");
1026 static_assert((std::is_same<decltype(fmin((int)0, (long double)0)), long double>::value), "");
1027 static_assert((std::is_same<decltype(fmin((float)0, (unsigned int)0)), double>::value), "");
1028 static_assert((std::is_same<decltype(fmin((double)0, (long)0)), double>::value), "");
1029 static_assert((std::is_same<decltype(fmin((long double)0, (unsigned long)0)), long double>::value), "");
1030 static_assert((std::is_same<decltype(fmin((int)0, (long long)0)), double>::value), "");
1031 static_assert((std::is_same<decltype(fmin((int)0, (unsigned long long)0)), double>::value), "");
1032 static_assert((std::is_same<decltype(fmin((double)0, (double)0)), double>::value), "");
1033 static_assert((std::is_same<decltype(fmin((long double)0, (long double)0)), long double>::value), "");
1034 static_assert((std::is_same<decltype(fmin((float)0, (double)0)), double>::value), "");
1035 static_assert((std::is_same<decltype(fmin((float)0, (long double)0)), long double>::value), "");
1036 static_assert((std::is_same<decltype(fmin((double)0, (long double)0)), long double>::value), "");
1037 static_assert((std::is_same<decltype(fminf(0,0)), float>::value), "");
1038 static_assert((std::is_same<decltype(fminl(0,0)), long double>::value), "");
1039 static_assert((std::is_same<decltype(fmin((int)0, (int)0)), double>::value), "");
1040 static_assert((std::is_same<decltype(fmin(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1041 assert(fmin(1,0) == 0);
1042 }
1043
test_hypot()1044 void test_hypot()
1045 {
1046 static_assert((std::is_same<decltype(hypot((float)0, (float)0)), float>::value), "");
1047 static_assert((std::is_same<decltype(hypot((bool)0, (float)0)), double>::value), "");
1048 static_assert((std::is_same<decltype(hypot((unsigned short)0, (double)0)), double>::value), "");
1049 static_assert((std::is_same<decltype(hypot((int)0, (long double)0)), long double>::value), "");
1050 static_assert((std::is_same<decltype(hypot((float)0, (unsigned int)0)), double>::value), "");
1051 static_assert((std::is_same<decltype(hypot((double)0, (long)0)), double>::value), "");
1052 static_assert((std::is_same<decltype(hypot((long double)0, (unsigned long)0)), long double>::value), "");
1053 static_assert((std::is_same<decltype(hypot((int)0, (long long)0)), double>::value), "");
1054 static_assert((std::is_same<decltype(hypot((int)0, (unsigned long long)0)), double>::value), "");
1055 static_assert((std::is_same<decltype(hypot((double)0, (double)0)), double>::value), "");
1056 static_assert((std::is_same<decltype(hypot((long double)0, (long double)0)), long double>::value), "");
1057 static_assert((std::is_same<decltype(hypot((float)0, (double)0)), double>::value), "");
1058 static_assert((std::is_same<decltype(hypot((float)0, (long double)0)), long double>::value), "");
1059 static_assert((std::is_same<decltype(hypot((double)0, (long double)0)), long double>::value), "");
1060 static_assert((std::is_same<decltype(hypotf(0,0)), float>::value), "");
1061 static_assert((std::is_same<decltype(hypotl(0,0)), long double>::value), "");
1062 static_assert((std::is_same<decltype(hypot((int)0, (int)0)), double>::value), "");
1063 static_assert((std::is_same<decltype(hypot(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1064 assert(hypot(3,4) == 5);
1065 }
1066
test_ilogb()1067 void test_ilogb()
1068 {
1069 static_assert((std::is_same<decltype(ilogb((float)0)), int>::value), "");
1070 static_assert((std::is_same<decltype(ilogb((bool)0)), int>::value), "");
1071 static_assert((std::is_same<decltype(ilogb((unsigned short)0)), int>::value), "");
1072 static_assert((std::is_same<decltype(ilogb((int)0)), int>::value), "");
1073 static_assert((std::is_same<decltype(ilogb((unsigned int)0)), int>::value), "");
1074 static_assert((std::is_same<decltype(ilogb((long)0)), int>::value), "");
1075 static_assert((std::is_same<decltype(ilogb((unsigned long)0)), int>::value), "");
1076 static_assert((std::is_same<decltype(ilogb((long long)0)), int>::value), "");
1077 static_assert((std::is_same<decltype(ilogb((unsigned long long)0)), int>::value), "");
1078 static_assert((std::is_same<decltype(ilogb((double)0)), int>::value), "");
1079 static_assert((std::is_same<decltype(ilogb((long double)0)), int>::value), "");
1080 static_assert((std::is_same<decltype(ilogbf(0)), int>::value), "");
1081 static_assert((std::is_same<decltype(ilogbl(0)), int>::value), "");
1082 static_assert((std::is_same<decltype(ilogb(Ambiguous())), Ambiguous>::value), "");
1083 assert(ilogb(1) == 0);
1084 }
1085
test_lgamma()1086 void test_lgamma()
1087 {
1088 static_assert((std::is_same<decltype(lgamma((float)0)), float>::value), "");
1089 static_assert((std::is_same<decltype(lgamma((bool)0)), double>::value), "");
1090 static_assert((std::is_same<decltype(lgamma((unsigned short)0)), double>::value), "");
1091 static_assert((std::is_same<decltype(lgamma((int)0)), double>::value), "");
1092 static_assert((std::is_same<decltype(lgamma((unsigned int)0)), double>::value), "");
1093 static_assert((std::is_same<decltype(lgamma((long)0)), double>::value), "");
1094 static_assert((std::is_same<decltype(lgamma((unsigned long)0)), double>::value), "");
1095 static_assert((std::is_same<decltype(lgamma((long long)0)), double>::value), "");
1096 static_assert((std::is_same<decltype(lgamma((unsigned long long)0)), double>::value), "");
1097 static_assert((std::is_same<decltype(lgamma((double)0)), double>::value), "");
1098 static_assert((std::is_same<decltype(lgamma((long double)0)), long double>::value), "");
1099 static_assert((std::is_same<decltype(lgammaf(0)), float>::value), "");
1100 static_assert((std::is_same<decltype(lgammal(0)), long double>::value), "");
1101 static_assert((std::is_same<decltype(lgamma(Ambiguous())), Ambiguous>::value), "");
1102 assert(lgamma(1) == 0);
1103 }
1104
test_llrint()1105 void test_llrint()
1106 {
1107 static_assert((std::is_same<decltype(llrint((float)0)), long long>::value), "");
1108 static_assert((std::is_same<decltype(llrint((bool)0)), long long>::value), "");
1109 static_assert((std::is_same<decltype(llrint((unsigned short)0)), long long>::value), "");
1110 static_assert((std::is_same<decltype(llrint((int)0)), long long>::value), "");
1111 static_assert((std::is_same<decltype(llrint((unsigned int)0)), long long>::value), "");
1112 static_assert((std::is_same<decltype(llrint((long)0)), long long>::value), "");
1113 static_assert((std::is_same<decltype(llrint((unsigned long)0)), long long>::value), "");
1114 static_assert((std::is_same<decltype(llrint((long long)0)), long long>::value), "");
1115 static_assert((std::is_same<decltype(llrint((unsigned long long)0)), long long>::value), "");
1116 static_assert((std::is_same<decltype(llrint((double)0)), long long>::value), "");
1117 static_assert((std::is_same<decltype(llrint((long double)0)), long long>::value), "");
1118 static_assert((std::is_same<decltype(llrintf(0)), long long>::value), "");
1119 static_assert((std::is_same<decltype(llrintl(0)), long long>::value), "");
1120 static_assert((std::is_same<decltype(llrint(Ambiguous())), Ambiguous>::value), "");
1121 assert(llrint(1) == 1LL);
1122 }
1123
test_llround()1124 void test_llround()
1125 {
1126 static_assert((std::is_same<decltype(llround((float)0)), long long>::value), "");
1127 static_assert((std::is_same<decltype(llround((bool)0)), long long>::value), "");
1128 static_assert((std::is_same<decltype(llround((unsigned short)0)), long long>::value), "");
1129 static_assert((std::is_same<decltype(llround((int)0)), long long>::value), "");
1130 static_assert((std::is_same<decltype(llround((unsigned int)0)), long long>::value), "");
1131 static_assert((std::is_same<decltype(llround((long)0)), long long>::value), "");
1132 static_assert((std::is_same<decltype(llround((unsigned long)0)), long long>::value), "");
1133 static_assert((std::is_same<decltype(llround((long long)0)), long long>::value), "");
1134 static_assert((std::is_same<decltype(llround((unsigned long long)0)), long long>::value), "");
1135 static_assert((std::is_same<decltype(llround((double)0)), long long>::value), "");
1136 static_assert((std::is_same<decltype(llround((long double)0)), long long>::value), "");
1137 static_assert((std::is_same<decltype(llroundf(0)), long long>::value), "");
1138 static_assert((std::is_same<decltype(llroundl(0)), long long>::value), "");
1139 static_assert((std::is_same<decltype(llround(Ambiguous())), Ambiguous>::value), "");
1140 assert(llround(1) == 1LL);
1141 }
1142
test_log1p()1143 void test_log1p()
1144 {
1145 static_assert((std::is_same<decltype(log1p((float)0)), float>::value), "");
1146 static_assert((std::is_same<decltype(log1p((bool)0)), double>::value), "");
1147 static_assert((std::is_same<decltype(log1p((unsigned short)0)), double>::value), "");
1148 static_assert((std::is_same<decltype(log1p((int)0)), double>::value), "");
1149 static_assert((std::is_same<decltype(log1p((unsigned int)0)), double>::value), "");
1150 static_assert((std::is_same<decltype(log1p((long)0)), double>::value), "");
1151 static_assert((std::is_same<decltype(log1p((unsigned long)0)), double>::value), "");
1152 static_assert((std::is_same<decltype(log1p((long long)0)), double>::value), "");
1153 static_assert((std::is_same<decltype(log1p((unsigned long long)0)), double>::value), "");
1154 static_assert((std::is_same<decltype(log1p((double)0)), double>::value), "");
1155 static_assert((std::is_same<decltype(log1p((long double)0)), long double>::value), "");
1156 static_assert((std::is_same<decltype(log1pf(0)), float>::value), "");
1157 static_assert((std::is_same<decltype(log1pl(0)), long double>::value), "");
1158 static_assert((std::is_same<decltype(log1p(Ambiguous())), Ambiguous>::value), "");
1159 assert(log1p(0) == 0);
1160 }
1161
test_log2()1162 void test_log2()
1163 {
1164 static_assert((std::is_same<decltype(log2((float)0)), float>::value), "");
1165 static_assert((std::is_same<decltype(log2((bool)0)), double>::value), "");
1166 static_assert((std::is_same<decltype(log2((unsigned short)0)), double>::value), "");
1167 static_assert((std::is_same<decltype(log2((int)0)), double>::value), "");
1168 static_assert((std::is_same<decltype(log2((unsigned int)0)), double>::value), "");
1169 static_assert((std::is_same<decltype(log2((long)0)), double>::value), "");
1170 static_assert((std::is_same<decltype(log2((unsigned long)0)), double>::value), "");
1171 static_assert((std::is_same<decltype(log2((long long)0)), double>::value), "");
1172 static_assert((std::is_same<decltype(log2((unsigned long long)0)), double>::value), "");
1173 static_assert((std::is_same<decltype(log2((double)0)), double>::value), "");
1174 static_assert((std::is_same<decltype(log2((long double)0)), long double>::value), "");
1175 static_assert((std::is_same<decltype(log2f(0)), float>::value), "");
1176 static_assert((std::is_same<decltype(log2l(0)), long double>::value), "");
1177 static_assert((std::is_same<decltype(log2(Ambiguous())), Ambiguous>::value), "");
1178 assert(log2(1) == 0);
1179 }
1180
test_logb()1181 void test_logb()
1182 {
1183 static_assert((std::is_same<decltype(logb((float)0)), float>::value), "");
1184 static_assert((std::is_same<decltype(logb((bool)0)), double>::value), "");
1185 static_assert((std::is_same<decltype(logb((unsigned short)0)), double>::value), "");
1186 static_assert((std::is_same<decltype(logb((int)0)), double>::value), "");
1187 static_assert((std::is_same<decltype(logb((unsigned int)0)), double>::value), "");
1188 static_assert((std::is_same<decltype(logb((long)0)), double>::value), "");
1189 static_assert((std::is_same<decltype(logb((unsigned long)0)), double>::value), "");
1190 static_assert((std::is_same<decltype(logb((long long)0)), double>::value), "");
1191 static_assert((std::is_same<decltype(logb((unsigned long long)0)), double>::value), "");
1192 static_assert((std::is_same<decltype(logb((double)0)), double>::value), "");
1193 static_assert((std::is_same<decltype(logb((long double)0)), long double>::value), "");
1194 static_assert((std::is_same<decltype(logbf(0)), float>::value), "");
1195 static_assert((std::is_same<decltype(logbl(0)), long double>::value), "");
1196 static_assert((std::is_same<decltype(logb(Ambiguous())), Ambiguous>::value), "");
1197 assert(logb(1) == 0);
1198 }
1199
test_lrint()1200 void test_lrint()
1201 {
1202 static_assert((std::is_same<decltype(lrint((float)0)), long>::value), "");
1203 static_assert((std::is_same<decltype(lrint((bool)0)), long>::value), "");
1204 static_assert((std::is_same<decltype(lrint((unsigned short)0)), long>::value), "");
1205 static_assert((std::is_same<decltype(lrint((int)0)), long>::value), "");
1206 static_assert((std::is_same<decltype(lrint((unsigned int)0)), long>::value), "");
1207 static_assert((std::is_same<decltype(lrint((long)0)), long>::value), "");
1208 static_assert((std::is_same<decltype(lrint((unsigned long)0)), long>::value), "");
1209 static_assert((std::is_same<decltype(lrint((long long)0)), long>::value), "");
1210 static_assert((std::is_same<decltype(lrint((unsigned long long)0)), long>::value), "");
1211 static_assert((std::is_same<decltype(lrint((double)0)), long>::value), "");
1212 static_assert((std::is_same<decltype(lrint((long double)0)), long>::value), "");
1213 static_assert((std::is_same<decltype(lrintf(0)), long>::value), "");
1214 static_assert((std::is_same<decltype(lrintl(0)), long>::value), "");
1215 static_assert((std::is_same<decltype(lrint(Ambiguous())), Ambiguous>::value), "");
1216 assert(lrint(1) == 1L);
1217 }
1218
test_lround()1219 void test_lround()
1220 {
1221 static_assert((std::is_same<decltype(lround((float)0)), long>::value), "");
1222 static_assert((std::is_same<decltype(lround((bool)0)), long>::value), "");
1223 static_assert((std::is_same<decltype(lround((unsigned short)0)), long>::value), "");
1224 static_assert((std::is_same<decltype(lround((int)0)), long>::value), "");
1225 static_assert((std::is_same<decltype(lround((unsigned int)0)), long>::value), "");
1226 static_assert((std::is_same<decltype(lround((long)0)), long>::value), "");
1227 static_assert((std::is_same<decltype(lround((unsigned long)0)), long>::value), "");
1228 static_assert((std::is_same<decltype(lround((long long)0)), long>::value), "");
1229 static_assert((std::is_same<decltype(lround((unsigned long long)0)), long>::value), "");
1230 static_assert((std::is_same<decltype(lround((double)0)), long>::value), "");
1231 static_assert((std::is_same<decltype(lround((long double)0)), long>::value), "");
1232 static_assert((std::is_same<decltype(lroundf(0)), long>::value), "");
1233 static_assert((std::is_same<decltype(lroundl(0)), long>::value), "");
1234 static_assert((std::is_same<decltype(lround(Ambiguous())), Ambiguous>::value), "");
1235 assert(lround(1) == 1L);
1236 }
1237
test_nan()1238 void test_nan()
1239 {
1240 static_assert((std::is_same<decltype(nan("")), double>::value), "");
1241 static_assert((std::is_same<decltype(nanf("")), float>::value), "");
1242 static_assert((std::is_same<decltype(nanl("")), long double>::value), "");
1243 }
1244
test_nearbyint()1245 void test_nearbyint()
1246 {
1247 static_assert((std::is_same<decltype(nearbyint((float)0)), float>::value), "");
1248 static_assert((std::is_same<decltype(nearbyint((bool)0)), double>::value), "");
1249 static_assert((std::is_same<decltype(nearbyint((unsigned short)0)), double>::value), "");
1250 static_assert((std::is_same<decltype(nearbyint((int)0)), double>::value), "");
1251 static_assert((std::is_same<decltype(nearbyint((unsigned int)0)), double>::value), "");
1252 static_assert((std::is_same<decltype(nearbyint((long)0)), double>::value), "");
1253 static_assert((std::is_same<decltype(nearbyint((unsigned long)0)), double>::value), "");
1254 static_assert((std::is_same<decltype(nearbyint((long long)0)), double>::value), "");
1255 static_assert((std::is_same<decltype(nearbyint((unsigned long long)0)), double>::value), "");
1256 static_assert((std::is_same<decltype(nearbyint((double)0)), double>::value), "");
1257 static_assert((std::is_same<decltype(nearbyint((long double)0)), long double>::value), "");
1258 static_assert((std::is_same<decltype(nearbyintf(0)), float>::value), "");
1259 static_assert((std::is_same<decltype(nearbyintl(0)), long double>::value), "");
1260 static_assert((std::is_same<decltype(nearbyint(Ambiguous())), Ambiguous>::value), "");
1261 assert(nearbyint(1) == 1);
1262 }
1263
test_nextafter()1264 void test_nextafter()
1265 {
1266 static_assert((std::is_same<decltype(nextafter((float)0, (float)0)), float>::value), "");
1267 static_assert((std::is_same<decltype(nextafter((bool)0, (float)0)), double>::value), "");
1268 static_assert((std::is_same<decltype(nextafter((unsigned short)0, (double)0)), double>::value), "");
1269 static_assert((std::is_same<decltype(nextafter((int)0, (long double)0)), long double>::value), "");
1270 static_assert((std::is_same<decltype(nextafter((float)0, (unsigned int)0)), double>::value), "");
1271 static_assert((std::is_same<decltype(nextafter((double)0, (long)0)), double>::value), "");
1272 static_assert((std::is_same<decltype(nextafter((long double)0, (unsigned long)0)), long double>::value), "");
1273 static_assert((std::is_same<decltype(nextafter((int)0, (long long)0)), double>::value), "");
1274 static_assert((std::is_same<decltype(nextafter((int)0, (unsigned long long)0)), double>::value), "");
1275 static_assert((std::is_same<decltype(nextafter((double)0, (double)0)), double>::value), "");
1276 static_assert((std::is_same<decltype(nextafter((long double)0, (long double)0)), long double>::value), "");
1277 static_assert((std::is_same<decltype(nextafter((float)0, (double)0)), double>::value), "");
1278 static_assert((std::is_same<decltype(nextafter((float)0, (long double)0)), long double>::value), "");
1279 static_assert((std::is_same<decltype(nextafter((double)0, (long double)0)), long double>::value), "");
1280 static_assert((std::is_same<decltype(nextafterf(0,0)), float>::value), "");
1281 static_assert((std::is_same<decltype(nextafterl(0,0)), long double>::value), "");
1282 static_assert((std::is_same<decltype(nextafter((int)0, (int)0)), double>::value), "");
1283 static_assert((std::is_same<decltype(nextafter(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1284 assert(nextafter(0,1) == hexfloat<double>(0x1, 0, -1074));
1285 }
1286
test_nexttoward()1287 void test_nexttoward()
1288 {
1289 static_assert((std::is_same<decltype(nexttoward((float)0, (long double)0)), float>::value), "");
1290 static_assert((std::is_same<decltype(nexttoward((bool)0, (long double)0)), double>::value), "");
1291 static_assert((std::is_same<decltype(nexttoward((unsigned short)0, (long double)0)), double>::value), "");
1292 static_assert((std::is_same<decltype(nexttoward((int)0, (long double)0)), double>::value), "");
1293 static_assert((std::is_same<decltype(nexttoward((unsigned int)0, (long double)0)), double>::value), "");
1294 static_assert((std::is_same<decltype(nexttoward((long)0, (long double)0)), double>::value), "");
1295 static_assert((std::is_same<decltype(nexttoward((unsigned long)0, (long double)0)), double>::value), "");
1296 static_assert((std::is_same<decltype(nexttoward((long long)0, (long double)0)), double>::value), "");
1297 static_assert((std::is_same<decltype(nexttoward((unsigned long long)0, (long double)0)), double>::value), "");
1298 static_assert((std::is_same<decltype(nexttoward((double)0, (long double)0)), double>::value), "");
1299 static_assert((std::is_same<decltype(nexttoward((long double)0, (long double)0)), long double>::value), "");
1300 static_assert((std::is_same<decltype(nexttowardf(0, (long double)0)), float>::value), "");
1301 static_assert((std::is_same<decltype(nexttowardl(0, (long double)0)), long double>::value), "");
1302 static_assert((std::is_same<decltype(nexttoward(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1303 assert(nexttoward(0, 1) == hexfloat<double>(0x1, 0, -1074));
1304 }
1305
test_remainder()1306 void test_remainder()
1307 {
1308 static_assert((std::is_same<decltype(remainder((float)0, (float)0)), float>::value), "");
1309 static_assert((std::is_same<decltype(remainder((bool)0, (float)0)), double>::value), "");
1310 static_assert((std::is_same<decltype(remainder((unsigned short)0, (double)0)), double>::value), "");
1311 static_assert((std::is_same<decltype(remainder((int)0, (long double)0)), long double>::value), "");
1312 static_assert((std::is_same<decltype(remainder((float)0, (unsigned int)0)), double>::value), "");
1313 static_assert((std::is_same<decltype(remainder((double)0, (long)0)), double>::value), "");
1314 static_assert((std::is_same<decltype(remainder((long double)0, (unsigned long)0)), long double>::value), "");
1315 static_assert((std::is_same<decltype(remainder((int)0, (long long)0)), double>::value), "");
1316 static_assert((std::is_same<decltype(remainder((int)0, (unsigned long long)0)), double>::value), "");
1317 static_assert((std::is_same<decltype(remainder((double)0, (double)0)), double>::value), "");
1318 static_assert((std::is_same<decltype(remainder((long double)0, (long double)0)), long double>::value), "");
1319 static_assert((std::is_same<decltype(remainder((float)0, (double)0)), double>::value), "");
1320 static_assert((std::is_same<decltype(remainder((float)0, (long double)0)), long double>::value), "");
1321 static_assert((std::is_same<decltype(remainder((double)0, (long double)0)), long double>::value), "");
1322 static_assert((std::is_same<decltype(remainderf(0,0)), float>::value), "");
1323 static_assert((std::is_same<decltype(remainderl(0,0)), long double>::value), "");
1324 static_assert((std::is_same<decltype(remainder((int)0, (int)0)), double>::value), "");
1325 static_assert((std::is_same<decltype(remainder(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1326 assert(remainder(0.5,1) == 0.5);
1327 }
1328
test_remquo()1329 void test_remquo()
1330 {
1331 int ip;
1332 static_assert((std::is_same<decltype(remquo((float)0, (float)0, &ip)), float>::value), "");
1333 static_assert((std::is_same<decltype(remquo((bool)0, (float)0, &ip)), double>::value), "");
1334 static_assert((std::is_same<decltype(remquo((unsigned short)0, (double)0, &ip)), double>::value), "");
1335 static_assert((std::is_same<decltype(remquo((int)0, (long double)0, &ip)), long double>::value), "");
1336 static_assert((std::is_same<decltype(remquo((float)0, (unsigned int)0, &ip)), double>::value), "");
1337 static_assert((std::is_same<decltype(remquo((double)0, (long)0, &ip)), double>::value), "");
1338 static_assert((std::is_same<decltype(remquo((long double)0, (unsigned long)0, &ip)), long double>::value), "");
1339 static_assert((std::is_same<decltype(remquo((int)0, (long long)0, &ip)), double>::value), "");
1340 static_assert((std::is_same<decltype(remquo((int)0, (unsigned long long)0, &ip)), double>::value), "");
1341 static_assert((std::is_same<decltype(remquo((double)0, (double)0, &ip)), double>::value), "");
1342 static_assert((std::is_same<decltype(remquo((long double)0, (long double)0, &ip)), long double>::value), "");
1343 static_assert((std::is_same<decltype(remquo((float)0, (double)0, &ip)), double>::value), "");
1344 static_assert((std::is_same<decltype(remquo((float)0, (long double)0, &ip)), long double>::value), "");
1345 static_assert((std::is_same<decltype(remquo((double)0, (long double)0, &ip)), long double>::value), "");
1346 static_assert((std::is_same<decltype(remquof(0,0, &ip)), float>::value), "");
1347 static_assert((std::is_same<decltype(remquol(0,0, &ip)), long double>::value), "");
1348 static_assert((std::is_same<decltype(remquo((int)0, (int)0, &ip)), double>::value), "");
1349 static_assert((std::is_same<decltype(remquo(Ambiguous(), Ambiguous(), &ip)), Ambiguous>::value), "");
1350 assert(remquo(0.5,1, &ip) == 0.5);
1351 }
1352
test_rint()1353 void test_rint()
1354 {
1355 static_assert((std::is_same<decltype(rint((float)0)), float>::value), "");
1356 static_assert((std::is_same<decltype(rint((bool)0)), double>::value), "");
1357 static_assert((std::is_same<decltype(rint((unsigned short)0)), double>::value), "");
1358 static_assert((std::is_same<decltype(rint((int)0)), double>::value), "");
1359 static_assert((std::is_same<decltype(rint((unsigned int)0)), double>::value), "");
1360 static_assert((std::is_same<decltype(rint((long)0)), double>::value), "");
1361 static_assert((std::is_same<decltype(rint((unsigned long)0)), double>::value), "");
1362 static_assert((std::is_same<decltype(rint((long long)0)), double>::value), "");
1363 static_assert((std::is_same<decltype(rint((unsigned long long)0)), double>::value), "");
1364 static_assert((std::is_same<decltype(rint((double)0)), double>::value), "");
1365 static_assert((std::is_same<decltype(rint((long double)0)), long double>::value), "");
1366 static_assert((std::is_same<decltype(rintf(0)), float>::value), "");
1367 static_assert((std::is_same<decltype(rintl(0)), long double>::value), "");
1368 static_assert((std::is_same<decltype(rint(Ambiguous())), Ambiguous>::value), "");
1369 assert(rint(1) == 1);
1370 }
1371
test_round()1372 void test_round()
1373 {
1374 static_assert((std::is_same<decltype(round((float)0)), float>::value), "");
1375 static_assert((std::is_same<decltype(round((bool)0)), double>::value), "");
1376 static_assert((std::is_same<decltype(round((unsigned short)0)), double>::value), "");
1377 static_assert((std::is_same<decltype(round((int)0)), double>::value), "");
1378 static_assert((std::is_same<decltype(round((unsigned int)0)), double>::value), "");
1379 static_assert((std::is_same<decltype(round((long)0)), double>::value), "");
1380 static_assert((std::is_same<decltype(round((unsigned long)0)), double>::value), "");
1381 static_assert((std::is_same<decltype(round((long long)0)), double>::value), "");
1382 static_assert((std::is_same<decltype(round((unsigned long long)0)), double>::value), "");
1383 static_assert((std::is_same<decltype(round((double)0)), double>::value), "");
1384 static_assert((std::is_same<decltype(round((long double)0)), long double>::value), "");
1385 static_assert((std::is_same<decltype(roundf(0)), float>::value), "");
1386 static_assert((std::is_same<decltype(roundl(0)), long double>::value), "");
1387 static_assert((std::is_same<decltype(round(Ambiguous())), Ambiguous>::value), "");
1388 assert(round(1) == 1);
1389 }
1390
test_scalbln()1391 void test_scalbln()
1392 {
1393 static_assert((std::is_same<decltype(scalbln((float)0, (long)0)), float>::value), "");
1394 static_assert((std::is_same<decltype(scalbln((bool)0, (long)0)), double>::value), "");
1395 static_assert((std::is_same<decltype(scalbln((unsigned short)0, (long)0)), double>::value), "");
1396 static_assert((std::is_same<decltype(scalbln((int)0, (long)0)), double>::value), "");
1397 static_assert((std::is_same<decltype(scalbln((unsigned int)0, (long)0)), double>::value), "");
1398 static_assert((std::is_same<decltype(scalbln((long)0, (long)0)), double>::value), "");
1399 static_assert((std::is_same<decltype(scalbln((unsigned long)0, (long)0)), double>::value), "");
1400 static_assert((std::is_same<decltype(scalbln((long long)0, (long)0)), double>::value), "");
1401 static_assert((std::is_same<decltype(scalbln((unsigned long long)0, (long)0)), double>::value), "");
1402 static_assert((std::is_same<decltype(scalbln((double)0, (long)0)), double>::value), "");
1403 static_assert((std::is_same<decltype(scalbln((long double)0, (long)0)), long double>::value), "");
1404 static_assert((std::is_same<decltype(scalblnf(0, (long)0)), float>::value), "");
1405 static_assert((std::is_same<decltype(scalblnl(0, (long)0)), long double>::value), "");
1406 static_assert((std::is_same<decltype(scalbln(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1407 assert(scalbln(1, 1) == 2);
1408 }
1409
test_scalbn()1410 void test_scalbn()
1411 {
1412 static_assert((std::is_same<decltype(scalbn((float)0, (int)0)), float>::value), "");
1413 static_assert((std::is_same<decltype(scalbn((bool)0, (int)0)), double>::value), "");
1414 static_assert((std::is_same<decltype(scalbn((unsigned short)0, (int)0)), double>::value), "");
1415 static_assert((std::is_same<decltype(scalbn((int)0, (int)0)), double>::value), "");
1416 static_assert((std::is_same<decltype(scalbn((unsigned int)0, (int)0)), double>::value), "");
1417 static_assert((std::is_same<decltype(scalbn((long)0, (int)0)), double>::value), "");
1418 static_assert((std::is_same<decltype(scalbn((unsigned long)0, (int)0)), double>::value), "");
1419 static_assert((std::is_same<decltype(scalbn((long long)0, (int)0)), double>::value), "");
1420 static_assert((std::is_same<decltype(scalbn((unsigned long long)0, (int)0)), double>::value), "");
1421 static_assert((std::is_same<decltype(scalbn((double)0, (int)0)), double>::value), "");
1422 static_assert((std::is_same<decltype(scalbn((long double)0, (int)0)), long double>::value), "");
1423 static_assert((std::is_same<decltype(scalbnf(0, (int)0)), float>::value), "");
1424 static_assert((std::is_same<decltype(scalbnl(0, (int)0)), long double>::value), "");
1425 static_assert((std::is_same<decltype(scalbn(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1426 assert(scalbn(1, 1) == 2);
1427 }
1428
test_tgamma()1429 void test_tgamma()
1430 {
1431 static_assert((std::is_same<decltype(tgamma((float)0)), float>::value), "");
1432 static_assert((std::is_same<decltype(tgamma((bool)0)), double>::value), "");
1433 static_assert((std::is_same<decltype(tgamma((unsigned short)0)), double>::value), "");
1434 static_assert((std::is_same<decltype(tgamma((int)0)), double>::value), "");
1435 static_assert((std::is_same<decltype(tgamma((unsigned int)0)), double>::value), "");
1436 static_assert((std::is_same<decltype(tgamma((long)0)), double>::value), "");
1437 static_assert((std::is_same<decltype(tgamma((unsigned long)0)), double>::value), "");
1438 static_assert((std::is_same<decltype(tgamma((long long)0)), double>::value), "");
1439 static_assert((std::is_same<decltype(tgamma((unsigned long long)0)), double>::value), "");
1440 static_assert((std::is_same<decltype(tgamma((double)0)), double>::value), "");
1441 static_assert((std::is_same<decltype(tgamma((long double)0)), long double>::value), "");
1442 static_assert((std::is_same<decltype(tgammaf(0)), float>::value), "");
1443 static_assert((std::is_same<decltype(tgammal(0)), long double>::value), "");
1444 static_assert((std::is_same<decltype(tgamma(Ambiguous())), Ambiguous>::value), "");
1445 assert(tgamma(1) == 1);
1446 }
1447
test_trunc()1448 void test_trunc()
1449 {
1450 static_assert((std::is_same<decltype(trunc((float)0)), float>::value), "");
1451 static_assert((std::is_same<decltype(trunc((bool)0)), double>::value), "");
1452 static_assert((std::is_same<decltype(trunc((unsigned short)0)), double>::value), "");
1453 static_assert((std::is_same<decltype(trunc((int)0)), double>::value), "");
1454 static_assert((std::is_same<decltype(trunc((unsigned int)0)), double>::value), "");
1455 static_assert((std::is_same<decltype(trunc((long)0)), double>::value), "");
1456 static_assert((std::is_same<decltype(trunc((unsigned long)0)), double>::value), "");
1457 static_assert((std::is_same<decltype(trunc((long long)0)), double>::value), "");
1458 static_assert((std::is_same<decltype(trunc((unsigned long long)0)), double>::value), "");
1459 static_assert((std::is_same<decltype(trunc((double)0)), double>::value), "");
1460 static_assert((std::is_same<decltype(trunc((long double)0)), long double>::value), "");
1461 static_assert((std::is_same<decltype(truncf(0)), float>::value), "");
1462 static_assert((std::is_same<decltype(truncl(0)), long double>::value), "");
1463 static_assert((std::is_same<decltype(trunc(Ambiguous())), Ambiguous>::value), "");
1464 assert(trunc(1) == 1);
1465 }
1466
main()1467 int main()
1468 {
1469 test_abs();
1470 test_acos();
1471 test_asin();
1472 test_atan();
1473 test_atan2();
1474 test_ceil();
1475 test_cos();
1476 test_cosh();
1477 test_exp();
1478 test_fabs();
1479 test_floor();
1480 test_fmod();
1481 test_frexp();
1482 test_ldexp();
1483 test_log();
1484 test_log10();
1485 test_modf();
1486 test_pow();
1487 test_sin();
1488 test_sinh();
1489 test_sqrt();
1490 test_tan();
1491 test_tanh();
1492 test_signbit();
1493 test_fpclassify();
1494 test_isfinite();
1495 test_isnormal();
1496 test_isgreater();
1497 test_isgreaterequal();
1498 test_isinf();
1499 test_isless();
1500 test_islessequal();
1501 test_islessgreater();
1502 test_isnan();
1503 test_isunordered();
1504 test_acosh();
1505 test_asinh();
1506 test_atanh();
1507 test_cbrt();
1508 test_copysign();
1509 test_erf();
1510 test_erfc();
1511 test_exp2();
1512 test_expm1();
1513 test_fdim();
1514 test_fma();
1515 test_fmax();
1516 test_fmin();
1517 test_hypot();
1518 test_ilogb();
1519 test_lgamma();
1520 test_llrint();
1521 test_llround();
1522 test_log1p();
1523 test_log2();
1524 test_logb();
1525 test_lrint();
1526 test_lround();
1527 test_nan();
1528 test_nearbyint();
1529 test_nextafter();
1530 test_nexttoward();
1531 test_remainder();
1532 test_remquo();
1533 test_rint();
1534 test_round();
1535 test_scalbln();
1536 test_scalbn();
1537 test_tgamma();
1538 test_trunc();
1539 }
1540