diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2009-07-23 18:38:22 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2009-07-23 18:38:22 +0000 |
commit | 7cf8aefccfe2f2ac63ce5f0791b53694cb38a54b (patch) | |
tree | a2111588d46122f6a79724d1ee665e0d9e5eeaa7 | |
parent | 88e18fedad6803c5f9abdbcf1c4a51c25e12706c (diff) | |
download | gcc-7cf8aefccfe2f2ac63ce5f0791b53694cb38a54b.zip gcc-7cf8aefccfe2f2ac63ce5f0791b53694cb38a54b.tar.gz gcc-7cf8aefccfe2f2ac63ce5f0791b53694cb38a54b.tar.bz2 |
cmath (abs(_Tp)): Add.
2009-07-23 Paolo Carlini <paolo.carlini@oracle.com>
* include/c_std/cmath (abs(_Tp)): Add.
* include/c_global/cmath (abs(_Tp)): Likewise.
* testsuite/26_numerics/headers/cmath/overloads.cc: Extend.
From-SVN: r150022
-rw-r--r-- | libstdc++-v3/ChangeLog | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/c_global/cmath | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/c_std/cmath | 18 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads.cc | 19 |
4 files changed, 43 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a7303bd..7ca37c7 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,11 @@ 2009-07-23 Paolo Carlini <paolo.carlini@oracle.com> + * include/c_std/cmath (abs(_Tp)): Add. + * include/c_global/cmath (abs(_Tp)): Likewise. + * testsuite/26_numerics/headers/cmath/overloads.cc: Extend. + +2009-07-23 Paolo Carlini <paolo.carlini@oracle.com> + * doc/html/ext/lwg-closed.html: Update to R65. * doc/html/ext/lwg-defects.html: Likewise. * doc/html/ext/lwg-active.html: Likewise. diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath index 9a63a01..a5c31c4 100644 --- a/libstdc++-v3/include/c_global/cmath +++ b/libstdc++-v3/include/c_global/cmath @@ -102,6 +102,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std) abs(long double __x) { return __builtin_fabsl(__x); } + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + abs(_Tp __x) + { return __builtin_fabs(__x); } + using ::acos; inline float diff --git a/libstdc++-v3/include/c_std/cmath b/libstdc++-v3/include/c_std/cmath index a0bebc9..3ee1393 100644 --- a/libstdc++-v3/include/c_std/cmath +++ b/libstdc++-v3/include/c_std/cmath @@ -93,6 +93,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std) abs(long double __x) { return __builtin_fabsl(__x); } + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + abs(_Tp __x) + { return __builtin_fabs(__x); } + using ::acos; inline float @@ -120,8 +126,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return __builtin_asinl(__x); } template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, - double>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type asin(_Tp __x) { return __builtin_asin(__x); } @@ -136,8 +142,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return __builtin_atanl(__x); } template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, - double>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type atan(_Tp __x) { return __builtin_atan(__x); } @@ -293,8 +299,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<typename _Tp> inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type - ldexp(_Tp __x, int __exp) - { return __builtin_ldexp(__x, __exp); } + ldexp(_Tp __x, int __exp) + { return __builtin_ldexp(__x, __exp); } using ::log; diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads.cc index 4d41a96..4418bc3 100644 --- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads.cc +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads.cc @@ -1,3 +1,21 @@ +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + // PR 3181 // Origin: pete@toyon.com @@ -8,6 +26,7 @@ int main() int i = -1; int j = 9; double ans; + ans = std::abs(i); ans = std::acos(i); ans = std::asin(i); ans = std::atan(i); |