Boost logo

Boost Users :

Subject: [Boost-users] [phoenix] using dereference and increment operator
From: Kim Kuen Tang (kuentang_at_[hidden])
Date: 2009-07-19 05:15:34


Hi all,

the following piece of code compiled with boost 1.39:

std::vector<double> u(11,1.0), w(11,3.0);
std::vector<double>::const_iterator it=w.begin();
double value=(*ph::ref(it)++)();

But if i use the expression *ph::ref(it)++ as a functional in an algorithm,

        std::generate(u.begin(),u.end(),*phoenix::ref(it)++ );

  the compilation fails with the following error:

>c:\boost\boost_msvc_2008\include\boost-1_39\boost\fusion\container\vector\detail\vector_n.hpp(68)
: error C2440: '<function-style-cast>' : cannot convert from 'const
boost::phoenix::composite<EvalPolicy,EvalTuple>' to
'boost::fusion::vector_data1<Derived,T0>'
1> with
1> [
1> EvalPolicy=boost::phoenix::post_increment_eval,
1>
EvalTuple=boost::fusion::vector<boost::phoenix::reference<std::_Vector_const_iterator<double,std::allocator<double>>>,boost::fusion::void_,boost::fusion::void_,boost::fusion::void_,boost::fusion::void_,boost::fusion::void_,boost::fusion::void_,boost::fusion::void_,boost::fusion::void_,boost::fusion::void_>
1> ]
1> and
1> [
1>
Derived=boost::fusion::vector1<boost::phoenix::reference<std::_Vector_const_iterator<double,std::allocator<double>>>>,
1>
T0=boost::phoenix::reference<std::_Vector_const_iterator<double,std::allocator<double>>>
1> ]
1> No constructor could take the source type, or constructor
overload resolution was ambiguous

I remember that the compilation was fine when using boost 1.38.
( I need to check this.)

Here is the code that produces the errors:

# include <algorithm>
# include <vector>

# include <boost/spirit/include/phoenix.hpp>
using namespace boost;

int main()
{

        std::vector<double> u(11,1.0), w(11,3.0);
        std::vector<double>::const_iterator it=w.begin();
        double value=(*phoenix::ref(it)++)();
        it=w.begin();
        std::generate(u.begin(),u.end(),*phoenix::ref(it)++ );

     return 0;
}

With regards,
Kim Tang


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