[lambda] return statement wrapper

Hi,
does a return statement wrapper exist in Boost.Lambda? I'd like to be able
to do something conceptually similar to the following:
--
#include

From: "Johan Nilsson"
void foo() { int const shouldBe3 = ( lambda::bind(&bar, 1), lambda::bind(&bar, 2), lambda::return(3) // Yes, this conflicts with the regular "return" statement, but you get the idea )();
assert(3 == shouldBe3); }
int const shouldBe3 = ( lambda::bind(&bar, 1), lambda::bind(&bar, 2), 3 )();

Peter Dimov wrote:
From: "Johan Nilsson"
void foo() { int const shouldBe3 = ( lambda::bind(&bar, 1), lambda::bind(&bar, 2), lambda::return(3) // Yes, this conflicts with the regular "return" statement, but you get the idea )();
assert(3 == shouldBe3); }
int const shouldBe3 = ( lambda::bind(&bar, 1), lambda::bind(&bar, 2), 3 )();
Now, that's what I call _embarrasingly_ simple. How stupid of me. To my defence, the above question originated from a problem I had in a more complex scenario of doing a very similar thing, where I did try to specify the return value by using lambda::constant. When that didn't work I simplified the code and posted the above without trying it out, using a custom functor instead for the original code. I just now tried to revert to using the composite lambda expression and it just works, so I probably made a typo and misinterpreted the error messages earlier. Sorry for the noise. / Johan
participants (2)
-
Johan Nilsson
-
Peter Dimov