Boost logo

Boost Users :

Subject: [Boost-users] [lambda] Help figuring out variable substitution, lazy functions, etc.? Should I be looking at Phoenix
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2009-08-03 08:58:29


I have been trying to prevent variable substitution with boost::lambda and
cannot figure out how to prevent variable substitution.

Here is a (simplified) version:
double first_moment(double x)
{
    return x;
}

//And create a function
auto myfunc = first_moment(_1);
cout << myfunc(2.0);

... This doesn't compile, and every permutation I can think of using
protect, etc. fails as well.

Now I realize that this looks like a job for "bind" (which works fine of
course) but this is a simplified pattern of the notation I want. Is there
any way to do this with protect, unlambda, etc. around the _1?

Are other libraries like Phoenix a better place to look for this kind of
functionality? Do people see Phoenix as the evolution of boost lambda or
are these likely to remain in parallel? Should I stick with C++0X lambdas?

Thanks,
Jesse



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