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

source code of libcxx/test/std/numerics/c.math/cmath.pass.cpp