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