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