diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2017-01-25 15:01:05 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2017-01-25 15:01:05 +0000 |
commit | 536c221d20d42459739e34e3a5aba8268cf48a6f (patch) | |
tree | 493bd6545f0a7185424b11d26531ab57a6d3096f /libstdc++-v3/include/std/complex | |
parent | a5d6927fef24c2cae73e473f8c997631eeb63152 (diff) |
PR libstdc++/70607 make proj(T) and conj(T) return complex<T>
PR libstdc++/61791
PR libstdc++/70607
* include/std/complex (real(T), imag(T)): Add _GLIBCXX_CONSTEXPR.
(proj(T), conj(T)): Change return types per DR 1522.
* include/tr1/complex (conj): Remove overloads and use std::conj.
* testsuite/26_numerics/complex/dr781_dr1137.cc: Rename to...
* testsuite/26_numerics/complex/dr781.cc: ... this, and update.
* testsuite/26_numerics/complex/value_operations/constexpr2.cc: Test
real(T) and imag(T). Allow testing for C++11 too.
From-SVN: r244900
Diffstat (limited to 'libstdc++-v3/include/std/complex')
-rw-r--r-- | libstdc++-v3/include/std/complex | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 12b6e41382a..6342c98e88a 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -1840,7 +1840,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type + _GLIBCXX_CONSTEXPR inline typename __gnu_cxx::__promote<_Tp>::__type imag(_Tp) { return _Tp(); } @@ -1853,7 +1853,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type + _GLIBCXX_CONSTEXPR inline typename __gnu_cxx::__promote<_Tp>::__type real(_Tp __x) { return __x; } @@ -1921,16 +1921,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __complex_proj(__z); } #endif - // DR 1137. template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type + inline std::complex<typename __gnu_cxx::__promote<_Tp>::__type> proj(_Tp __x) - { return __x; } + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return std::proj(std::complex<__type>(__x)); + } template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type + inline std::complex<typename __gnu_cxx::__promote<_Tp>::__type> conj(_Tp __x) - { return __x; } + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return std::complex<__type>(__x, -__type()); + } _GLIBCXX_END_NAMESPACE_VERSION |