blob: 724935623db78c038e02a5353c10785cdd2601a7 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===---------------------------- cmath -----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_CMATH
12#define _LIBCPP_CMATH
13
14/*
15 cmath synopsis
16
17Macros:
18
19 HUGE_VAL
20 HUGE_VALF // C99
21 HUGE_VALL // C99
22 INFINITY // C99
23 NAN // C99
24 FP_INFINITE // C99
25 FP_NAN // C99
26 FP_NORMAL // C99
27 FP_SUBNORMAL // C99
28 FP_ZERO // C99
29 FP_FAST_FMA // C99
30 FP_FAST_FMAF // C99
31 FP_FAST_FMAL // C99
32 FP_ILOGB0 // C99
33 FP_ILOGBNAN // C99
34 MATH_ERRNO // C99
35 MATH_ERREXCEPT // C99
36 math_errhandling // C99
37
38namespace std
39{
40
41Types:
42
43 float_t // C99
44 double_t // C99
45
46// C90
47
48floating_point abs(floating_point x);
49
50floating_point acos (arithmetic x);
51float acosf(float x);
52long double acosl(long double x);
53
54floating_point asin (arithmetic x);
55float asinf(float x);
56long double asinl(long double x);
57
58floating_point atan (arithmetic x);
59float atanf(float x);
60long double atanl(long double x);
61
62floating_point atan2 (arithmetic y, arithmetic x);
63float atan2f(float y, float x);
64long double atan2l(long double y, long double x);
65
66floating_point ceil (arithmetic x);
67float ceilf(float x);
68long double ceill(long double x);
69
70floating_point cos (arithmetic x);
71float cosf(float x);
72long double cosl(long double x);
73
74floating_point cosh (arithmetic x);
75float coshf(float x);
76long double coshl(long double x);
77
78floating_point exp (arithmetic x);
79float expf(float x);
80long double expl(long double x);
81
82floating_point fabs (arithmetic x);
83float fabsf(float x);
84long double fabsl(long double x);
85
86floating_point floor (arithmetic x);
87float floorf(float x);
88long double floorl(long double x);
89
90floating_point fmod (arithmetic x, arithmetic y);
91float fmodf(float x, float y);
92long double fmodl(long double x, long double y);
93
94floating_point frexp (arithmetic value, int* exp);
95float frexpf(float value, int* exp);
96long double frexpl(long double value, int* exp);
97
98floating_point ldexp (arithmetic value, int exp);
99float ldexpf(float value, int exp);
100long double ldexpl(long double value, int exp);
101
102floating_point log (arithmetic x);
103float logf(float x);
104long double logl(long double x);
105
106floating_point log10 (arithmetic x);
107float log10f(float x);
108long double log10l(long double x);
109
110floating_point modf (floating_point value, floating_point* iptr);
111float modff(float value, float* iptr);
112long double modfl(long double value, long double* iptr);
113
114floating_point pow (arithmetic x, arithmetic y);
115float powf(float x, float y);
116long double powl(long double x, long double y);
117
118floating_point sin (arithmetic x);
119float sinf(float x);
120long double sinl(long double x);
121
122floating_point sinh (arithmetic x);
123float sinhf(float x);
124long double sinhl(long double x);
125
126floating_point sqrt (arithmetic x);
127float sqrtf(float x);
128long double sqrtl(long double x);
129
130floating_point tan (arithmetic x);
131float tanf(float x);
132long double tanl(long double x);
133
134floating_point tanh (arithmetic x);
135float tanhf(float x);
136long double tanhl(long double x);
137
138// C99
139
Howard Hinnantb05a5562013-01-14 20:56:22 +0000140bool signbit(arithmetic x);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000141
Howard Hinnantb05a5562013-01-14 20:56:22 +0000142int fpclassify(arithmetic x);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000143
Howard Hinnantb05a5562013-01-14 20:56:22 +0000144bool isfinite(arithmetic x);
145bool isinf(arithmetic x);
146bool isnan(arithmetic x);
147bool isnormal(arithmetic x);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000148
Howard Hinnantb05a5562013-01-14 20:56:22 +0000149bool isgreater(arithmetic x, arithmetic y);
150bool isgreaterequal(arithmetic x, arithmetic y);
151bool isless(arithmetic x, arithmetic y);
152bool islessequal(arithmetic x, arithmetic y);
153bool islessgreater(arithmetic x, arithmetic y);
154bool isunordered(arithmetic x, arithmetic y);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000155
156floating_point acosh (arithmetic x);
157float acoshf(float x);
158long double acoshl(long double x);
159
160floating_point asinh (arithmetic x);
161float asinhf(float x);
162long double asinhl(long double x);
163
164floating_point atanh (arithmetic x);
165float atanhf(float x);
166long double atanhl(long double x);
167
168floating_point cbrt (arithmetic x);
169float cbrtf(float x);
170long double cbrtl(long double x);
171
172floating_point copysign (arithmetic x, arithmetic y);
173float copysignf(float x, float y);
174long double copysignl(long double x, long double y);
175
176floating_point erf (arithmetic x);
177float erff(float x);
178long double erfl(long double x);
179
180floating_point erfc (arithmetic x);
181float erfcf(float x);
182long double erfcl(long double x);
183
184floating_point exp2 (arithmetic x);
185float exp2f(float x);
186long double exp2l(long double x);
187
188floating_point expm1 (arithmetic x);
189float expm1f(float x);
190long double expm1l(long double x);
191
192floating_point fdim (arithmetic x, arithmetic y);
193float fdimf(float x, float y);
194long double fdiml(long double x, long double y);
195
196floating_point fma (arithmetic x, arithmetic y, arithmetic z);
197float fmaf(float x, float y, float z);
198long double fmal(long double x, long double y, long double z);
199
200floating_point fmax (arithmetic x, arithmetic y);
201float fmaxf(float x, float y);
202long double fmaxl(long double x, long double y);
203
204floating_point fmin (arithmetic x, arithmetic y);
205float fminf(float x, float y);
206long double fminl(long double x, long double y);
207
208floating_point hypot (arithmetic x, arithmetic y);
209float hypotf(float x, float y);
210long double hypotl(long double x, long double y);
211
Marshall Clow2c154392016-05-17 14:52:19 +0000212double hypot(double x, double y, double z); // C++17
213float hypot(float x, float y, float z); // C++17
214long double hypot(long double x, long double y, long double z); // C++17
215
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000216int ilogb (arithmetic x);
217int ilogbf(float x);
218int ilogbl(long double x);
219
220floating_point lgamma (arithmetic x);
221float lgammaf(float x);
222long double lgammal(long double x);
223
224long long llrint (arithmetic x);
225long long llrintf(float x);
226long long llrintl(long double x);
227
228long long llround (arithmetic x);
229long long llroundf(float x);
230long long llroundl(long double x);
231
232floating_point log1p (arithmetic x);
233float log1pf(float x);
234long double log1pl(long double x);
235
236floating_point log2 (arithmetic x);
237float log2f(float x);
238long double log2l(long double x);
239
240floating_point logb (arithmetic x);
241float logbf(float x);
242long double logbl(long double x);
243
244long lrint (arithmetic x);
245long lrintf(float x);
246long lrintl(long double x);
247
248long lround (arithmetic x);
249long lroundf(float x);
250long lroundl(long double x);
251
252double nan (const char* str);
253float nanf(const char* str);
254long double nanl(const char* str);
255
256floating_point nearbyint (arithmetic x);
257float nearbyintf(float x);
258long double nearbyintl(long double x);
259
260floating_point nextafter (arithmetic x, arithmetic y);
261float nextafterf(float x, float y);
262long double nextafterl(long double x, long double y);
263
264floating_point nexttoward (arithmetic x, long double y);
265float nexttowardf(float x, long double y);
266long double nexttowardl(long double x, long double y);
267
268floating_point remainder (arithmetic x, arithmetic y);
269float remainderf(float x, float y);
270long double remainderl(long double x, long double y);
271
272floating_point remquo (arithmetic x, arithmetic y, int* pquo);
273float remquof(float x, float y, int* pquo);
274long double remquol(long double x, long double y, int* pquo);
275
276floating_point rint (arithmetic x);
277float rintf(float x);
278long double rintl(long double x);
279
280floating_point round (arithmetic x);
281float roundf(float x);
282long double roundl(long double x);
283
284floating_point scalbln (arithmetic x, long ex);
285float scalblnf(float x, long ex);
286long double scalblnl(long double x, long ex);
287
288floating_point scalbn (arithmetic x, int ex);
289float scalbnf(float x, int ex);
290long double scalbnl(long double x, int ex);
291
292floating_point tgamma (arithmetic x);
293float tgammaf(float x);
294long double tgammal(long double x);
295
296floating_point trunc (arithmetic x);
297float truncf(float x);
298long double truncl(long double x);
299
300} // std
301
302*/
303
304#include <__config>
305#include <math.h>
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000306
Howard Hinnant08e17472011-10-17 20:05:10 +0000307#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000308#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000309#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000310
311_LIBCPP_BEGIN_NAMESPACE_STD
312
Howard Hinnant0a111112011-05-13 21:52:40 +0000313using ::signbit;
314using ::fpclassify;
315using ::isfinite;
316using ::isinf;
317using ::isnan;
318using ::isnormal;
319using ::isgreater;
320using ::isgreaterequal;
321using ::isless;
322using ::islessequal;
323using ::islessgreater;
324using ::isunordered;
325using ::isunordered;
326
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000327using ::float_t;
328using ::double_t;
329
Richard Smith4faa3942015-10-08 20:40:34 +0000330#ifndef _AIX
Eric Fiselier0b6f8ed2015-03-18 15:24:18 +0000331using ::abs;
332#endif
333
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000334using ::acos;
335using ::acosf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000336using ::asin;
337using ::asinf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000338using ::atan;
339using ::atanf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000340using ::atan2;
341using ::atan2f;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000342using ::ceil;
343using ::ceilf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000344using ::cos;
345using ::cosf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000346using ::cosh;
347using ::coshf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000348
349using ::exp;
350using ::expf;
351
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000352using ::fabs;
353using ::fabsf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000354using ::floor;
355using ::floorf;
Richard Smith4faa3942015-10-08 20:40:34 +0000356
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000357using ::fmod;
358using ::fmodf;
Richard Smith4faa3942015-10-08 20:40:34 +0000359
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000360using ::frexp;
361using ::frexpf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000362using ::ldexp;
363using ::ldexpf;
Richard Smith4faa3942015-10-08 20:40:34 +0000364
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000365using ::log;
366using ::logf;
Richard Smith4faa3942015-10-08 20:40:34 +0000367
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000368using ::log10;
369using ::log10f;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000370using ::modf;
371using ::modff;
Richard Smith4faa3942015-10-08 20:40:34 +0000372
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000373using ::pow;
374using ::powf;
375
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000376using ::sin;
377using ::sinf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000378using ::sinh;
379using ::sinhf;
Richard Smith4faa3942015-10-08 20:40:34 +0000380
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000381using ::sqrt;
382using ::sqrtf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000383using ::tan;
384using ::tanf;
Richard Smith4faa3942015-10-08 20:40:34 +0000385
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000386using ::tanh;
387using ::tanhf;
388
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000389using ::acosh;
390using ::acoshf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000391using ::asinh;
392using ::asinhf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000393using ::atanh;
394using ::atanhf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000395using ::cbrt;
396using ::cbrtf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000397
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000398using ::copysign;
399using ::copysignf;
400
Howard Hinnante9df0a52013-08-01 18:17:34 +0000401#ifndef _LIBCPP_MSVCRT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000402using ::erf;
403using ::erff;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000404using ::erfc;
405using ::erfcf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000406using ::exp2;
407using ::exp2f;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000408using ::expm1;
409using ::expm1f;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000410using ::fdim;
411using ::fdimf;
Marshall Clow0d6dcb52014-03-05 17:09:51 +0000412using ::fmaf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000413using ::fma;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000414using ::fmax;
415using ::fmaxf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000416using ::fmin;
417using ::fminf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000418using ::hypot;
419using ::hypotf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000420using ::ilogb;
421using ::ilogbf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000422using ::lgamma;
423using ::lgammaf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000424using ::llrint;
425using ::llrintf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000426using ::llround;
427using ::llroundf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000428using ::log1p;
429using ::log1pf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000430using ::log2;
431using ::log2f;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000432using ::logb;
433using ::logbf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000434using ::lrint;
435using ::lrintf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000436using ::lround;
437using ::lroundf;
Howard Hinnante9df0a52013-08-01 18:17:34 +0000438#endif // _LIBCPP_MSVCRT
Howard Hinnante9df0a52013-08-01 18:17:34 +0000439
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000440using ::nan;
441using ::nanf;
Howard Hinnante9df0a52013-08-01 18:17:34 +0000442
Howard Hinnante9df0a52013-08-01 18:17:34 +0000443#ifndef _LIBCPP_MSVCRT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000444using ::nearbyint;
445using ::nearbyintf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000446using ::nextafter;
447using ::nextafterf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000448using ::nexttoward;
449using ::nexttowardf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000450using ::remainder;
451using ::remainderf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000452using ::remquo;
453using ::remquof;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000454using ::rint;
455using ::rintf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000456using ::round;
457using ::roundf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000458using ::scalbln;
459using ::scalblnf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000460using ::scalbn;
461using ::scalbnf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000462using ::tgamma;
463using ::tgammaf;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000464using ::trunc;
465using ::truncf;
Howard Hinnante9df0a52013-08-01 18:17:34 +0000466#endif // !_LIBCPP_MSVCRT
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000467
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000468using ::acosl;
469using ::asinl;
470using ::atanl;
471using ::atan2l;
472using ::ceill;
473using ::cosl;
474using ::coshl;
475using ::expl;
476using ::fabsl;
477using ::floorl;
478using ::fmodl;
479using ::frexpl;
480using ::ldexpl;
481using ::logl;
482using ::log10l;
483using ::modfl;
484using ::powl;
485using ::sinl;
486using ::sinhl;
487using ::sqrtl;
488using ::tanl;
Richard Smith4faa3942015-10-08 20:40:34 +0000489
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000490using ::tanhl;
491using ::acoshl;
492using ::asinhl;
493using ::atanhl;
494using ::cbrtl;
Richard Smith4faa3942015-10-08 20:40:34 +0000495
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000496using ::copysignl;
Richard Smith4faa3942015-10-08 20:40:34 +0000497
Howard Hinnante9df0a52013-08-01 18:17:34 +0000498#ifndef _LIBCPP_MSVCRT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000499using ::erfl;
500using ::erfcl;
501using ::exp2l;
502using ::expm1l;
503using ::fdiml;
504using ::fmal;
505using ::fmaxl;
506using ::fminl;
507using ::hypotl;
508using ::ilogbl;
509using ::lgammal;
510using ::llrintl;
511using ::llroundl;
512using ::log1pl;
513using ::log2l;
514using ::logbl;
515using ::lrintl;
516using ::lroundl;
517using ::nanl;
518using ::nearbyintl;
519using ::nextafterl;
520using ::nexttowardl;
521using ::remainderl;
522using ::remquol;
523using ::rintl;
524using ::roundl;
525using ::scalblnl;
526using ::scalbnl;
527using ::tgammal;
528using ::truncl;
Howard Hinnante9df0a52013-08-01 18:17:34 +0000529#endif // !_LIBCPP_MSVCRT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000530
Marshall Clow2c154392016-05-17 14:52:19 +0000531#if _LIBCPP_STD_VER > 14
532inline _LIBCPP_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); }
533inline _LIBCPP_INLINE_VISIBILITY double hypot( double x, double y, double z ) { return sqrt(x*x + y*y + z*z); }
534inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y, long double z ) { return sqrt(x*x + y*y + z*z); }
535
536template <class _A1, class _A2, class _A3>
537inline _LIBCPP_INLINE_VISIBILITY
Hal Finkeld24aba42016-10-01 20:38:44 +0000538typename __lazy_enable_if
Marshall Clow2c154392016-05-17 14:52:19 +0000539<
Hal Finkeld24aba42016-10-01 20:38:44 +0000540 is_arithmetic<_A1>::value &&
541 is_arithmetic<_A2>::value &&
542 is_arithmetic<_A3>::value,
543 __promote<_A1, _A2, _A3>
Marshall Clow2c154392016-05-17 14:52:19 +0000544>::type
545hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
546{
Hal Finkeld24aba42016-10-01 20:38:44 +0000547 typedef typename __promote<_A1, _A2, _A3>::type __result_type;
548 static_assert((!(is_same<_A1, __result_type>::value &&
549 is_same<_A2, __result_type>::value &&
550 is_same<_A3, __result_type>::value)), "");
Marshall Clow2c154392016-05-17 14:52:19 +0000551 return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
552}
553#endif
554
Hal Finkel970af072016-10-01 20:38:31 +0000555template <class _A1>
556_LIBCPP_ALWAYS_INLINE
Justin Lebarbb835ac2016-11-15 19:15:57 +0000557_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
Hal Finkel970af072016-10-01 20:38:31 +0000558__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
559{
560#if __has_builtin(__builtin_isnan)
561 return __builtin_isnan(__lcpp_x);
562#else
563 return isnan(__lcpp_x);
564#endif
565}
566
567template <class _A1>
568_LIBCPP_ALWAYS_INLINE
Justin Lebarbb835ac2016-11-15 19:15:57 +0000569_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
Hal Finkel970af072016-10-01 20:38:31 +0000570__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
571{
572 return isnan(__lcpp_x);
573}
574
575template <class _A1>
576_LIBCPP_ALWAYS_INLINE
Justin Lebarbb835ac2016-11-15 19:15:57 +0000577_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
Hal Finkel970af072016-10-01 20:38:31 +0000578__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
579{
580#if __has_builtin(__builtin_isinf)
581 return __builtin_isinf(__lcpp_x);
582#else
583 return isinf(__lcpp_x);
584#endif
585}
586
587template <class _A1>
588_LIBCPP_ALWAYS_INLINE
Justin Lebarbb835ac2016-11-15 19:15:57 +0000589_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
Hal Finkel970af072016-10-01 20:38:31 +0000590__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
591{
592 return isinf(__lcpp_x);
593}
594
595template <class _A1>
596_LIBCPP_ALWAYS_INLINE
Justin Lebarbb835ac2016-11-15 19:15:57 +0000597_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
Hal Finkel970af072016-10-01 20:38:31 +0000598__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
599{
600#if __has_builtin(__builtin_isfinite)
601 return __builtin_isfinite(__lcpp_x);
602#else
603 return isfinite(__lcpp_x);
604#endif
605}
606
607template <class _A1>
608_LIBCPP_ALWAYS_INLINE
Justin Lebarbb835ac2016-11-15 19:15:57 +0000609_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
Hal Finkel970af072016-10-01 20:38:31 +0000610__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
611{
612 return isfinite(__lcpp_x);
613}
614
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000615_LIBCPP_END_NAMESPACE_STD
616
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000617#endif // _LIBCPP_CMATH