|
Boost Users : |
Subject: Re: [Boost-users] [Fusion] transform / transform_view / binary sequence iteration
From: Hicham Mouline (hicham_at_[hidden])
Date: 2010-03-02 07:44:36
-----Original Message-----
From: "Thomas Taylor" [thomas.taylor_at_[hidden]]
Date: 02/03/2010 11:49 AM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] [Fusion] transform / transform_view / binary sequence
iteration
Hi!
Started out with tuple but soon moved to fusion as it suits my needs much
better, so thanks for fusion!
My problem is the following:
list<A,B,C> seq2(1,2,3);
list<W<A>,W<B>,W<C> > seq1;
struct fa
{
typedef unsigned int result_type;
template <typename S1, typename S2>
result_type operator()(const S1& s1, const S2& s2) const
{
return s1(s2); // this calls W<A>(A), W<B>(B), W<C>(C)
}
};
struct fb
{
typedef std::vector<unsigned int> result_type;
template <typename T>
result_type operator()(const result_type& a, const T& t) const
{
result_type a2(a);
a2.push_back(t);
return a2;
}
};
accumulate( transform(seq1,seq2,fa()),fb() );
/* The above yields an error:
no matching function for call to
âaccumulate(boost::fusion::transform_view<const
boost::fusion::list<W<double>, W<double>, W<double>, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_>, const
boost::fusion::list<double, double, double, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_>,
database::histogram::fb>) */
How can I use a transform_view (the result of transform(S1,S2,F)) as input
for accumulate?
Thank you,
Thomas
_______________________________________________
In my basic experience, this has been a matter of constness.
Checkout fusion docs and make sure you follow exactly the function signatures.
Oh! you need an initial state for accumulate()
rds,
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net