Boost logo

Boost Users :

Subject: [Boost-users] problem with boost::phoenix::lambda
From: Kim Kuen Tang (kuentang_at_[hidden])
Date: 2009-07-25 10:19:38


Hi all,

the following code

double abc=lambda(_a=*ref(it)++)[_a*2.0]()(); // here 'it' is an
       //iterator

produces the error C2440: 'initializing' : cannot convert from
'boost::phoenix::detail::error_expecting_arguments' to 'double'

which should not be. The two lines of code

let(_a=*ref(it)++)[_a*2.0](); //or

lambda(_a=*ref(it)++)[_a*2.0*arg1]()( val);

compile fine.

Perhaps someone has an answer to this error?
( I use boost trunk version and msvc 2008)

To reproduce the errors just compile the code below.

Best regards
Kim Tang

# include <algorithm>
# include <vector>

# include <boost/spirit/include/phoenix.hpp>

using namespace boost::phoenix;
using namespace boost::phoenix::arg_names;
using namespace boost::phoenix::local_names;

int main()
{

        std::vector<double> u(11,1.0);
        std::vector<double> w(11,2.0);
        std::vector<double>::const_iterator it=w.begin();
        //boost::phoenix::generate(ref(u)
        // ,lambda(_a=*ref(it)++)[_a*2.0 ]
        //)();

        double abc=lambda(_a=*ref(it)++)[_a*2.0]()();
     return 0;
}


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