mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-01 15:54:17 +08:00
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
This commit is contained in:
parent
394a378ca9
commit
3fd29fa912
@ -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),
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -76,11 +76,6 @@ namespace tr1
|
||||
|
||||
using std::real;
|
||||
|
||||
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)
|
||||
|
52
libstdc++-v3/testsuite/26_numerics/complex/dr844.cc
Normal file
52
libstdc++-v3/testsuite/26_numerics/complex/dr844.cc
Normal file
@ -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;
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user