diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2016-09-29 14:25:48 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2016-09-29 14:25:48 +0100 |
commit | 998e01a6d52296036e04294375f489e64cba6fd1 (patch) | |
tree | 2184da8f2893fd505034bb8efd739ec0c1bfbd97 | |
parent | a9087411ad024045963288b86f2a11840a30b489 (diff) | |
download | gcc-998e01a6d52296036e04294375f489e64cba6fd1.zip gcc-998e01a6d52296036e04294375f489e64cba6fd1.tar.gz gcc-998e01a6d52296036e04294375f489e64cba6fd1.tar.bz2 |
Define C++17 std::hypot without _GLIBCXX_USE_C99_MATH_TR1
* include/c_global/cmath (hypot, __hypot3): Move C++17 overloads
outside _GLIBCXX_USE_C99_MATH_TR1 condition.
From-SVN: r240620
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/c_global/cmath | 87 |
2 files changed, 52 insertions, 40 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d0e2980..2106912 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2016-09-29 Jonathan Wakely <jwakely@redhat.com> + + * include/c_global/cmath (hypot, __hypot3): Move C++17 overloads + outside _GLIBCXX_USE_C99_MATH_TR1 condition. + 2016-09-29 Alan Modra <amodra@gmail.com> * configure.ac (LONG_DOUBLE_COMPAT_FLAGS): New ACSUBST. diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath index fffa0e7..0e7c4ad 100644 --- a/libstdc++-v3/include/c_global/cmath +++ b/libstdc++-v3/include/c_global/cmath @@ -1455,46 +1455,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return hypot(__type(__x), __type(__y)); } -#if __cplusplus > 201402L -#define __cpp_lib_hypot 201603 - // [c.math.hypot3], three-dimensional hypotenuse - - template<typename _Tp> - inline _Tp - __hypot3(_Tp __x, _Tp __y, _Tp __z) - { - __x = std::abs(__x); - __y = std::abs(__y); - __z = std::abs(__z); - if (_Tp __a = __x < __y ? __y < __z ? __z : __y : __x < __z ? __z : __x) - return __a * std::sqrt((__x / __a) * (__x / __a) - + (__y / __a) * (__y / __a) - + (__z / __a) * (__z / __a)); - else - return {}; - } - - inline float - hypot(float __x, float __y, float __z) - { return std::__hypot3<float>(__x, __y, __z); } - - inline double - hypot(double __x, double __y, double __z) - { return std::__hypot3<double>(__x, __y, __z); } - - inline long double - hypot(long double __x, long double __y, long double __z) - { return std::__hypot3<long double>(__x, __y, __z); } - - template<typename _Tp, typename _Up, typename _Vp> - typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type - hypot(_Tp __x, _Up __y, _Vp __z) - { - using __type = typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type; - return std::__hypot3<__type>(__x, __y, __z); - } -#endif // C++17 - #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO constexpr int ilogb(float __x) @@ -1830,6 +1790,53 @@ _GLIBCXX_END_NAMESPACE_VERSION #endif // C++11 +#if __cplusplus > 201402L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // [c.math.hypot3], three-dimensional hypotenuse +#define __cpp_lib_hypot 201603 + + template<typename _Tp> + inline _Tp + __hypot3(_Tp __x, _Tp __y, _Tp __z) + { + __x = std::abs(__x); + __y = std::abs(__y); + __z = std::abs(__z); + if (_Tp __a = __x < __y ? __y < __z ? __z : __y : __x < __z ? __z : __x) + return __a * std::sqrt((__x / __a) * (__x / __a) + + (__y / __a) * (__y / __a) + + (__z / __a) * (__z / __a)); + else + return {}; + } + + inline float + hypot(float __x, float __y, float __z) + { return std::__hypot3<float>(__x, __y, __z); } + + inline double + hypot(double __x, double __y, double __z) + { return std::__hypot3<double>(__x, __y, __z); } + + inline long double + hypot(long double __x, long double __y, long double __z) + { return std::__hypot3<long double>(__x, __y, __z); } + + template<typename _Tp, typename _Up, typename _Vp> + typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type + hypot(_Tp __x, _Up __y, _Vp __z) + { + using __type = typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type; + return std::__hypot3<__type>(__x, __y, __z); + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++17 + + #if _GLIBCXX_USE_STD_SPEC_FUNCS # include <bits/specfun.h> #endif |