diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2008-06-12 10:17:53 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2008-06-12 10:17:53 +0000 |
commit | 3fd29fa912911b3db52046ef0d44144dd0e043ee (patch) | |
tree | 5fa8457f26dacc4e85ba8442365ab437f33de9f4 | |
parent | 394a378ca94d23f47d17a863ee7a0627c48a3754 (diff) | |
download | gcc-3fd29fa912911b3db52046ef0d44144dd0e043ee.zip gcc-3fd29fa912911b3db52046ef0d44144dd0e043ee.tar.gz gcc-3fd29fa912911b3db52046ef0d44144dd0e043ee.tar.bz2 |
complex (pow(const complex<>&, int)): Do not define in C++0x mode, per DR 844.
2008-06-12 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/complex (pow(const complex<>&, int)): Do not define in
C++0x mode, per DR 844.
* include/tr1/complex (pow(const complex<>&, int)): Remove.
* doc/xml/manual/intro.xml: Add an entry for DR 844.
* testsuite/26_numerics/complex/dr844.cc: New.
* testsuite/tr1/8_c_compatibility/complex/overloads_int.cc: Adjust.
From-SVN: r136694
-rw-r--r-- | libstdc++-v3/ChangeLog | 9 | ||||
-rw-r--r-- | libstdc++-v3/doc/xml/manual/intro.xml | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/std/complex | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/complex | 5 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/26_numerics/complex/dr844.cc | 52 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc | 13 |
6 files changed, 79 insertions, 15 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 94cbefa..933bff8 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2008-06-12 Paolo Carlini <paolo.carlini@oracle.com> + + * include/std/complex (pow(const complex<>&, int)): Do not define in + C++0x mode, per DR 844. + * include/tr1/complex (pow(const complex<>&, int)): Remove. + * doc/xml/manual/intro.xml: Add an entry for DR 844. + * testsuite/26_numerics/complex/dr844.cc: New. + * testsuite/tr1/8_c_compatibility/complex/overloads_int.cc: Adjust. + 2008-06-11 Paolo Carlini <paolo.carlini@oracle.com> * include/tr1_impl/hashtable (_Hashtable<>::cbegin(size_type), diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml index 309871b..e30e81d 100644 --- a/libstdc++-v3/doc/xml/manual/intro.xml +++ b/libstdc++-v3/doc/xml/manual/intro.xml @@ -677,6 +677,12 @@ </term> <listitem><para>In C++0x mode, add std::proj. </para></listitem></varlistentry> + + <varlistentry><term><ulink url="../ext/lwg-active.html#844">844</ulink>: + <emphasis>complex pow return type is ambiguous</emphasis> + </term> + <listitem><para>In C++0x mode, remove the pow(complex<T>, int) signature. + </para></listitem></varlistentry> </variablelist> </sect2> diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 0fa381c..c8845f6 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -82,8 +82,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<typename _Tp> complex<_Tp> log(const complex<_Tp>&); /// Return complex base 10 logarithm of @a z. template<typename _Tp> complex<_Tp> log10(const complex<_Tp>&); - /// Return complex cosine of @a z. +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + // DR 844. + /// Return @a x to the @a y'th power. template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, int); +#endif /// Return @a x to the @a y'th power. template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, const _Tp&); /// Return @a x to the @a y'th power. @@ -945,10 +948,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // 26.2.8/9 pow(__x, __y): Returns the complex power base of __x // raised to the __y-th power. The branch // cut is on the negative axis. +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 844. complex pow return type is ambiguous. template<typename _Tp> inline complex<_Tp> pow(const complex<_Tp>& __z, int __n) { return std::__pow_helper(__z, __n); } +#endif template<typename _Tp> complex<_Tp> diff --git a/libstdc++-v3/include/tr1/complex b/libstdc++-v3/include/tr1/complex index b571a59..88c37de 100644 --- a/libstdc++-v3/include/tr1/complex +++ b/libstdc++-v3/include/tr1/complex @@ -78,11 +78,6 @@ namespace tr1 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); } diff --git a/libstdc++-v3/testsuite/26_numerics/complex/dr844.cc b/libstdc++-v3/testsuite/26_numerics/complex/dr844.cc new file mode 100644 index 0000000..e9bb192 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/dr844.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-12 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include <complex> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +// DR 844. complex pow return type is ambiguous. +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::check_ret_type; + + typedef std::complex<float> cmplx_f_type; + typedef std::complex<double> cmplx_d_type; + typedef std::complex<long double> cmplx_ld_type; + + const int i1 = 1; + const float f1 = 1.0f; + const double d1 = 1.0; + const long double ld1 = 1.0l; + + check_ret_type<cmplx_d_type>(std::pow(cmplx_f_type(f1, f1), i1)); + VERIFY( std::pow(cmplx_f_type(f1, f1), i1) + == std::pow(cmplx_d_type(f1, f1), double(i1)) ); + check_ret_type<cmplx_d_type>(std::pow(cmplx_d_type(d1, d1), i1)); + check_ret_type<cmplx_ld_type>(std::pow(cmplx_ld_type(ld1, ld1), i1)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc index b018351..231581f 100644 --- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc +++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc @@ -1,6 +1,6 @@ // 2006-01-12 Paolo Carlini <pcarlini@suse.de> // -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008 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 @@ -64,18 +64,13 @@ void test01() typedef std::complex<int> cmplx_i_type; check_ret_type<cmplx_i_type>(std::tr1::polar(i1, i1)); - // NB: According to the letter of 8.1.9/3 the return type should be a - // cmplx_d_type, but the existing std::pow(const complex<>&, int) wins. - // check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_f_type(f1, f1), i1)); - check_ret_type<cmplx_f_type>(std::tr1::pow(cmplx_f_type(f1, f1), i1)); - + check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_f_type(f1, f1), i1)); check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_f_type(f1, f1), u1)); check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_f_type(f1, f1), l1)); check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_d_type(d1, d1), i1)); - // See last comment. - // VERIFY( std::tr1::pow(cmplx_d_type(d1, d1), i1) - // == std::tr1::pow(cmplx_d_type(d1, d1), double(i1)) ); + VERIFY( std::tr1::pow(cmplx_d_type(d1, d1), i1) + == std::tr1::pow(cmplx_d_type(d1, d1), double(i1)) ); VERIFY( std::tr1::pow(cmplx_d_type(d1, d1), u1) == std::tr1::pow(cmplx_d_type(d1, d1), double(u1)) ); VERIFY( std::tr1::pow(cmplx_d_type(d1, d1), l1) |