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