boost::lambda questions
I would like to be able to: * return multiple results from a lambda function * use temporary variables inside a lambda function, declared using BOOST_AUTO * I would need the ability to deduce the type of the returned values via BOOST_AUTO to declare the matching variables. I think I could use boost::tuple for this: const BOOST_AUTO(sTupleVar, someThing); const BOOST_AUTO(sFirstResult, get<0>(sTupleVar)); const BOOST_AUTO(sSecond, get<1>(sTupleVar)); But how to declare a local variable inside a lambda function? Peter
Peter Foelsche wrote:
I would like to be able to:
* return multiple results from a lambda function * use temporary variables inside a lambda function, declared using BOOST_AUTO * I would need the ability to deduce the type of the returned values via BOOST_AUTO to declare the matching variables.
I think I could use boost::tuple for this:
const BOOST_AUTO(sTupleVar, someThing); const BOOST_AUTO(sFirstResult, get<0>(sTupleVar)); const BOOST_AUTO(sSecond, get<1>(sTupleVar));
But how to declare a local variable inside a lambda function?
Peter
Hi Peter - I would recommend taking a look at the Phoenix library. It is more feature rich that Boost.Lambda. For local variables see here: http://www.boost.org/doc/libs/1_41_0/libs/spirit/phoenix/doc/html/phoenix/co... There are multiple methods for dealing with fusion sequences (tuples on steroids). You should find everything you need with Boost.Phoenix. It also has the upside of being more readable (imho). michael -- ---------------------------------- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com
participants (2)
-
Michael Caisse
-
Peter Foelsche