mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-23 09:07:26 +02:00
fix for #2355: discrepancy between std::accumulate and fusion::accumulate
[SVN r57125]
This commit is contained in:
@ -34,22 +34,22 @@ struct add_ints_only
|
||||
template<typename T>
|
||||
struct result;
|
||||
|
||||
template <typename T, typename State>
|
||||
struct result<add_ints_only(T,State)>
|
||||
template <typename State, typename T>
|
||||
struct result<add_ints_only(State, T)>
|
||||
{
|
||||
typedef typename boost::remove_const<
|
||||
typename boost::remove_reference<State>::type>::type type;
|
||||
};
|
||||
|
||||
template <typename T, typename State>
|
||||
State const&
|
||||
operator()(T const& x, State const& state) const
|
||||
template <typename State, typename T>
|
||||
State
|
||||
operator()(State const& state, T const& x) const
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
int
|
||||
operator()(int x, int state) const
|
||||
operator()(int state, int x) const
|
||||
{
|
||||
return x + state;
|
||||
}
|
||||
@ -60,13 +60,13 @@ struct count_ints
|
||||
template<typename T>
|
||||
struct result;
|
||||
|
||||
template <typename T, typename CountT>
|
||||
struct result<count_ints(T,CountT)>
|
||||
template <typename CountT, typename T>
|
||||
struct result<count_ints(CountT, T)>
|
||||
{
|
||||
typedef typename boost::remove_const<
|
||||
typename boost::remove_reference<T>::type>::type elem;
|
||||
typedef typename boost::remove_const<
|
||||
typename boost::remove_reference<CountT>::type>::type state;
|
||||
typedef typename boost::remove_const<
|
||||
typename boost::remove_reference<T>::type>::type elem;
|
||||
|
||||
typedef typename
|
||||
if_<
|
||||
@ -77,11 +77,11 @@ struct count_ints
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename T, typename CountT>
|
||||
typename result<count_ints(T, CountT)>::type
|
||||
operator()(T const&, CountT const&) const
|
||||
template <typename CountT, typename T>
|
||||
typename result<count_ints(CountT, T)>::type
|
||||
operator()(CountT const&, T const&) const
|
||||
{
|
||||
typedef typename result<count_ints(T, CountT)>::type result;
|
||||
typedef typename result<count_ints(CountT, T)>::type result;
|
||||
return result();
|
||||
}
|
||||
};
|
||||
@ -90,7 +90,7 @@ struct appender
|
||||
{
|
||||
typedef std::string result_type;
|
||||
|
||||
std::string operator()(char c, std::string const& str) const
|
||||
std::string operator()(std::string const& str, char c) const
|
||||
{
|
||||
return str + c;
|
||||
}
|
||||
@ -102,14 +102,14 @@ struct lvalue_adder
|
||||
struct result;
|
||||
|
||||
template<typename T0, typename T1>
|
||||
struct result<lvalue_adder(T0&, T1)>
|
||||
struct result<lvalue_adder(T0, T1&)>
|
||||
{
|
||||
// Second argument still needs to support rvalues - see definition of fusion::fold
|
||||
typedef T0 type;
|
||||
typedef T1 type;
|
||||
};
|
||||
|
||||
template<typename T0, typename T1>
|
||||
T0 operator()(T0& lhs, T1 const& rhs) const
|
||||
T1 operator()(T0 const& lhs, T1& rhs) const
|
||||
{
|
||||
return lhs + rhs;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace
|
||||
typedef int result_type;
|
||||
|
||||
template<int n, int batch>
|
||||
int operator()(distinct<n, batch> const& d, int state) const
|
||||
int operator()(int state, distinct<n, batch> const& d) const
|
||||
{
|
||||
return state + n;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ struct test_func
|
||||
typedef long result_type;
|
||||
|
||||
template <typename T>
|
||||
long operator()(T & elem, long value) const
|
||||
long operator()(long value, T & elem) const
|
||||
{
|
||||
elem += sizeof(T);
|
||||
return value + elem;
|
||||
|
@ -57,7 +57,7 @@ struct test_func
|
||||
typedef long result_type;
|
||||
|
||||
template <typename T>
|
||||
long operator()(T & elem, long value) const
|
||||
long operator()(long value, T & elem) const
|
||||
{
|
||||
elem += sizeof(T);
|
||||
return value + elem;
|
||||
|
@ -63,13 +63,13 @@ struct test_func
|
||||
typedef long result_type;
|
||||
|
||||
template <typename T>
|
||||
long operator()(T const & elem, long value) const
|
||||
long operator()(long value, T const & elem) const
|
||||
{
|
||||
return value + sizeof(T) * elem;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
long operator()(T & elem, long value) const
|
||||
long operator()(long value, T & elem) const
|
||||
{
|
||||
elem += sizeof(T);
|
||||
return value;
|
||||
|
Reference in New Issue
Block a user