|
1 | | -// -*- C++ -*- |
2 | | -#ifndef _EZCXX_ABS_OVERLOADS |
3 | | -#define _EZCXX_ABS_OVERLOADS |
4 | | - |
5 | | -#include <cdefs.h> |
6 | | - |
7 | | -#pragma clang system_header |
8 | | - |
9 | | -// https://cplusplus.github.io/LWG/issue2192 |
10 | | - |
11 | | -#ifndef _ABS_INT_DEFINED |
12 | | -#define _ABS_INT_DEFINED |
13 | | - |
14 | | -__BEGIN_DECLS |
15 | | - |
16 | | -int abs(int n); |
17 | | -long labs(long n); |
18 | | -long long llabs(long long n); |
19 | | - |
20 | | -#ifdef __SIZEOF_INT48__ |
21 | | -signed __int48 i48abs(signed __int48 n) __NOEXCEPT_CONST; |
22 | | -#endif // __SIZEOF_INT48__ |
23 | | - |
24 | | -__END_DECLS |
25 | | - |
26 | | -#endif // _ABS_INT_DEFINED |
27 | | - |
28 | | -#ifndef _ABS_FLOAT_DEFINED |
29 | | -#define _ABS_FLOAT_DEFINED |
30 | | - |
31 | | -extern "C" { |
32 | | - float fabsf(float); |
33 | | - double fabs(double); |
34 | | - long double fabsl(long double); |
35 | | -} // extern "C" |
36 | | - |
37 | | -#endif // _ABS_FLOAT_DEFINED |
38 | | - |
39 | | -namespace std { |
40 | | -using ::abs; |
41 | | -inline constexpr long abs(long __x) { return labs(__x); } |
42 | | -inline constexpr long long abs(long long __x) { return llabs(__x); } |
43 | | - |
44 | | -#ifdef __SIZEOF_INT48__ |
45 | | -using ::i48abs; |
46 | | -inline signed __int48 abs(signed __int48 __x) { return i48abs(__x); } |
47 | | -#endif // __SIZEOF_INT48__ |
48 | | - |
49 | | -inline constexpr float abs(float __x) { return fabsf(__x); } |
50 | | -inline constexpr double abs(double __x) { return fabs(__x); } |
51 | | -inline constexpr long double abs(long double __x) { return fabsl(__x); } |
52 | | -} |
53 | | - |
54 | | -#endif // _EZCXX_ABS_OVERLOADS |
| 1 | +// -*- C++ -*- |
| 2 | +#ifndef _EZCXX_ABS_OVERLOADS |
| 3 | +#define _EZCXX_ABS_OVERLOADS |
| 4 | + |
| 5 | +#include <cdefs.h> |
| 6 | + |
| 7 | +#pragma clang system_header |
| 8 | + |
| 9 | +// https://cplusplus.github.io/LWG/issue2192 |
| 10 | + |
| 11 | +#ifndef _ABS_INT_DEFINED |
| 12 | +#define _ABS_INT_DEFINED |
| 13 | + |
| 14 | +__BEGIN_DECLS |
| 15 | + |
| 16 | +int abs(int n); |
| 17 | +long labs(long n); |
| 18 | +long long llabs(long long n); |
| 19 | + |
| 20 | +#ifdef __SIZEOF_INT48__ |
| 21 | +signed __int48 i48abs(signed __int48 n) __NOEXCEPT_CONST; |
| 22 | +#endif // __SIZEOF_INT48__ |
| 23 | + |
| 24 | +__END_DECLS |
| 25 | + |
| 26 | +#endif // _ABS_INT_DEFINED |
| 27 | + |
| 28 | +#ifndef _ABS_FLOAT_DEFINED |
| 29 | +#define _ABS_FLOAT_DEFINED |
| 30 | + |
| 31 | +extern "C" { |
| 32 | + float fabsf(float); |
| 33 | + double fabs(double); |
| 34 | + long double fabsl(long double); |
| 35 | +} // extern "C" |
| 36 | + |
| 37 | +#endif // _ABS_FLOAT_DEFINED |
| 38 | + |
| 39 | +namespace std { |
| 40 | +using ::abs; |
| 41 | +inline constexpr long abs(long __x) { return labs(__x); } |
| 42 | +inline constexpr long long abs(long long __x) { return llabs(__x); } |
| 43 | + |
| 44 | +#ifdef __SIZEOF_INT48__ |
| 45 | +using ::i48abs; |
| 46 | +inline signed __int48 abs(signed __int48 __x) { return i48abs(__x); } |
| 47 | +#endif // __SIZEOF_INT48__ |
| 48 | + |
| 49 | +inline constexpr float abs(float __x) { return fabsf(__x); } |
| 50 | +inline constexpr double abs(double __x) { return fabs(__x); } |
| 51 | +inline constexpr long double abs(long double __x) { return fabsl(__x); } |
| 52 | +} |
| 53 | + |
| 54 | +#endif // _EZCXX_ABS_OVERLOADS |
0 commit comments