|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65631 - trunk/boost/math/special_functions
From: john_at_[hidden]
Date: 2010-09-27 10:36:22
Author: johnmaddock
Date: 2010-09-27 10:36:18 EDT (Mon, 27 Sep 2010)
New Revision: 65631
URL: http://svn.boost.org/trac/boost/changeset/65631
Log:
Fix integer argument promotion, to simplify code and suppress warnings.
Text files modified:
trunk/boost/math/special_functions/pow.hpp | 26 ++++++++++++--------------
1 files changed, 12 insertions(+), 14 deletions(-)
Modified: trunk/boost/math/special_functions/pow.hpp
==============================================================================
--- trunk/boost/math/special_functions/pow.hpp (original)
+++ trunk/boost/math/special_functions/pow.hpp 2010-09-27 10:36:18 EDT (Mon, 27 Sep 2010)
@@ -30,10 +30,9 @@
struct positive_power
{
template <typename T>
- static typename tools::promote_args<T>::type result(T base)
+ static T result(T base)
{
- typename tools::promote_args<T>::type power =
- positive_power<N/2>::result(base);
+ T power = positive_power<N/2>::result(base);
return power * power;
}
};
@@ -42,10 +41,9 @@
struct positive_power<N, 1>
{
template <typename T>
- static typename tools::promote_args<T>::type result(T base)
+ static T result(T base)
{
- typename tools::promote_args<T>::type power =
- positive_power<N/2>::result(base);
+ T power = positive_power<N/2>::result(base);
return base * power * power;
}
};
@@ -54,8 +52,7 @@
struct positive_power<1, 1>
{
template <typename T>
- static typename tools::promote_args<T>::type result(T base)
- { return base; }
+ static T result(T base){ return base; }
};
@@ -63,7 +60,7 @@
struct power_if_positive
{
template <typename T, class Policy>
- static typename tools::promote_args<T>::type result(T base, const Policy&)
+ static T result(T base, const Policy&)
{ return positive_power<N>::result(base); }
};
@@ -71,8 +68,7 @@
struct power_if_positive<N, false>
{
template <typename T, class Policy>
- static typename tools::promote_args<T>::type
- result(T base, const Policy& policy)
+ static T result(T base, const Policy& policy)
{
if (base == 0)
{
@@ -91,8 +87,7 @@
struct power_if_positive<0, true>
{
template <typename T, class Policy>
- static typename tools::promote_args<T>::type
- result(T base, const Policy& policy)
+ static T result(T base, const Policy& policy)
{
if (base == 0)
{
@@ -127,7 +122,10 @@
template <int N, typename T, class Policy>
inline typename tools::promote_args<T>::type pow(T base, const Policy& policy)
-{ return detail::select_power_if_positive<N>::type::result(base, policy); }
+{
+ typedef typename tools::promote_args<T>::type result_type;
+ return detail::select_power_if_positive<N>::type::result(static_cast<result_type>(base), policy);
+}
template <int N, typename T>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk