diff options
author | paolo <> | 2008-05-26 18:18:24 +0000 |
---|---|---|
committer | paolo <> | 2008-05-26 18:18:24 +0000 |
commit | 641875e79e4330990b9919f8526d1a54647c29d6 (patch) | |
tree | 1c714aed772d1688bc92edf6c7d871cc35e11712 /libstdc++-v3/include/tr1 | |
parent | a51b6b0cfedc0af273166343aece49f16ad96368 (diff) |
2008-05-26 Paolo Carlini <paolo.carlini@oracle.com>
* include/c_global/cmath (pow(float, int), pow(double, int),
pow(long double, int)): Do not define in C++0x mode, per DR 550.
* include/tr1_impl/cmath (pow): Do not bring in unconditionally
from namespace std.
* include/tr1/cmath (pow(double, double), pow(float, float),
pow(long double, long double), pow(_Tp, _Up)): Define.
* include/tr1/complex (pow): Do not bring in from namespace std.
(pow(const std::complex<_Tp>&, int), pow(const std::complex<_Tp>&,
const _Tp&), pow(const _Tp&, const std::complex<_Tp>&),
pow(const std::complex<_Tp>&, const std::complex<_Tp>&)): Define.
* include/tr1_impl/complex (pow(const std::complex<_Tp>&,
const _Up&), pow(const _Tp&, const std::complex<_Up>&),
pow(const std::complex<_Tp>&, const std::complex<_Up>&)): Always
define.
* doc/xml/manual/intro.xml: Add an entry for DR 550.
* testsuite/26_numerics/headers/cmath/dr550.cc: New.
* testsuite/tr1/8_c_compatibility/cmath/overloads.cc: Adjust.
Diffstat (limited to 'libstdc++-v3/include/tr1')
-rw-r--r-- | libstdc++-v3/include/tr1/cmath | 28 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/complex | 22 |
2 files changed, 48 insertions, 2 deletions
diff --git a/libstdc++-v3/include/tr1/cmath b/libstdc++-v3/include/tr1/cmath index 63e6a2e5fda..a9c5aecf018 100644 --- a/libstdc++-v3/include/tr1/cmath +++ b/libstdc++-v3/include/tr1/cmath @@ -56,6 +56,34 @@ # undef _GLIBCXX_INCLUDE_AS_TR1 #endif +namespace std +{ +namespace tr1 +{ + // DR 550. What should the return type of pow(float,int) be? + // NB: C++0x and TR1 != C++03. + inline double + pow(double __x, double __y) + { return std::pow(__x, __y); } + + inline float + pow(float __x, float __y) + { return std::pow(__x, __y); } + + inline long double + pow(long double __x, long double __y) + { return std::pow(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + pow(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(__type(__x), __type(__y)); + } +} +} + #include <bits/stl_algobase.h> #include <limits> #include <tr1/type_traits> diff --git a/libstdc++-v3/include/tr1/complex b/libstdc++-v3/include/tr1/complex index 8d14681e955..b571a5982ed 100644 --- a/libstdc++-v3/include/tr1/complex +++ b/libstdc++-v3/include/tr1/complex @@ -75,9 +75,27 @@ namespace tr1 } using std::real; - using std::pow; + + template<typename _Tp> + inline std::complex<_Tp> + pow(const std::complex<_Tp>& __x, int __n) + { return std::pow(__x, __n); } + + template<typename _Tp> + inline std::complex<_Tp> + pow(const std::complex<_Tp>& __x, const _Tp& __y) + { return std::pow(__x, __y); } + + template<typename _Tp> + inline std::complex<_Tp> + pow(const _Tp& __x, const std::complex<_Tp>& __y) + { return std::pow(__x, __y); } + + template<typename _Tp> + inline std::complex<_Tp> + pow(const std::complex<_Tp>& __x, const std::complex<_Tp>& __y) + { return std::pow(__x, __y); } } } #endif // _GLIBCXX_TR1_COMPLEX - |