Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::lambda questions
From: Michael Caisse (boost_at_[hidden])
Date: 2009-12-09 17:49:40


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/composite.html#phoenix.composite.scope.local_variables

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

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