mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-05 18:49:43 +08:00
cmath (pow(float, int), [...]): Do not define in C++0x mode, per DR 550.
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. From-SVN: r135955
This commit is contained in:
parent
ba977e1ad9
commit
774c3d8647
@ -1,3 +1,23 @@
|
||||
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.
|
||||
|
||||
2008-05-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/std/tuple: Ifndef __GXX_EXPERIMENTAL_CXX0X__ just error out.
|
||||
|
@ -611,6 +611,12 @@
|
||||
<listitem><para>Follow the straightforward proposed resolution.
|
||||
</para></listitem></varlistentry>
|
||||
|
||||
<varlistentry><term><ulink url="../ext/lwg-active.html#550">550</ulink>:
|
||||
<emphasis>What should the return type of pow(float,int) be?</emphasis>
|
||||
</term>
|
||||
<listitem><para>In C++0x mode, remove the pow(float,int), etc., signatures.
|
||||
</para></listitem></varlistentry>
|
||||
|
||||
<varlistentry><term><ulink url="../ext/lwg-defects.html#586">586</ulink>:
|
||||
<emphasis>string inserter not a formatted function</emphasis>
|
||||
</term>
|
||||
|
@ -367,7 +367,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
pow(long double __x, long double __y)
|
||||
{ return __builtin_powl(__x, __y); }
|
||||
|
||||
// DR 550.
|
||||
#ifndef __GXX_EXPERIMENTAL_CXX0X__
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// DR 550. What should the return type of pow(float,int) be?
|
||||
inline double
|
||||
pow(double __x, int __i)
|
||||
{ return __builtin_powi(__x, __i); }
|
||||
@ -379,6 +381,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
inline long double
|
||||
pow(long double __x, int __n)
|
||||
{ return __builtin_powil(__x, __n); }
|
||||
#endif
|
||||
|
||||
template<typename _Tp, typename _Up>
|
||||
inline
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
||||
|
@ -763,7 +763,9 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
return nexttoward(__type(__x), __y);
|
||||
}
|
||||
|
||||
using std::pow;
|
||||
// DR 550. What should the return type of pow(float,int) be?
|
||||
// NB: C++0x and TR1 != C++03.
|
||||
// using std::pow;
|
||||
|
||||
inline float
|
||||
remainder(float __x, float __y)
|
||||
|
@ -301,12 +301,11 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
fabs(const std::complex<_Tp>& __z)
|
||||
{ return std::abs(__z); }
|
||||
|
||||
|
||||
/// Additional overloads [8.1.9].
|
||||
#if (defined(_GLIBCXX_INCLUDE_AS_CXX0X) \
|
||||
|| (defined(_GLIBCXX_INCLUDE_AS_TR1) \
|
||||
&& !defined(__GXX_EXPERIMENTAL_CXX0X__)))
|
||||
|
||||
/// Additional overloads [8.1.9].
|
||||
template<typename _Tp>
|
||||
inline typename __gnu_cxx::__promote<_Tp>::__type
|
||||
arg(_Tp __x)
|
||||
@ -338,6 +337,8 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
real(_Tp __x)
|
||||
{ return __x; }
|
||||
|
||||
#endif
|
||||
|
||||
template<typename _Tp, typename _Up>
|
||||
inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type>
|
||||
pow(const std::complex<_Tp>& __x, const _Up& __y)
|
||||
@ -363,7 +364,5 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
std::complex<__type>(__y));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_TR1
|
||||
}
|
||||
|
47
libstdc++-v3/testsuite/26_numerics/headers/cmath/dr550.cc
Normal file
47
libstdc++-v3/testsuite/26_numerics/headers/cmath/dr550.cc
Normal file
@ -0,0 +1,47 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// 2008-05-26 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 <cmath>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_tr1.h>
|
||||
|
||||
// DR 550. What should the return type of pow(float,int) be?
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using __gnu_test::check_ret_type;
|
||||
|
||||
const int i1 = 1;
|
||||
const float f1 = 1.0f;
|
||||
const double d1 = 1.0;
|
||||
const long double ld1 = 1.0l;
|
||||
|
||||
check_ret_type<double>(std::pow(f1, i1));
|
||||
VERIFY( std::pow(f1, i1) == std::pow(double(f1), double(i1)) );
|
||||
check_ret_type<double>(std::pow(d1, i1));
|
||||
check_ret_type<long double>(std::pow(ld1, i1));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
@ -206,9 +206,7 @@ void test01()
|
||||
check_ret_type<long double>(std::tr1::pow(ld0, d0));
|
||||
check_ret_type<double>(std::tr1::pow(i0, i0));
|
||||
check_ret_type<double>(std::tr1::pow(d0, i0));
|
||||
// DR 550.
|
||||
// check_ret_type<double>(std::tr1::pow(f0, i0));
|
||||
check_ret_type<float>(std::tr1::pow(f0, i0));
|
||||
check_ret_type<double>(std::tr1::pow(f0, i0));
|
||||
|
||||
check_ret_type<double>(std::tr1::remainder(d0, d0));
|
||||
check_ret_type<double>(std::tr1::remainder(d0, f0));
|
||||
|
Loading…
Reference in New Issue
Block a user