I am trying to understand the difference between these different bind approaches. There is a similar question at boost::bind and boost::phoenix::bind
But, if anyone can explain this with examples it would be great. Also is it true that boost::phoenix is a superset of boost::bind, booost::lambda libraries?
Boost. Phoenix is the most important Boost library for functional programming. While libraries like Boost. Bind or Boost. Lambda provide some support for functional programming, Boost.
boost::bind is a generalization of the standard functions std::bind1st and std::bind2nd. It supports arbitrary function objects, functions, function pointers, and member function pointers, and is able to bind any argument to a specific value or route input arguments into arbitrary positions.
I think the story is (though I'm not old enough to tell the whole story), boost::bind was first created to replace the hard-to-use bind1st/bind2nd in C++98, and it achieves its goal and now part of C++11. But also as last 10 years saw the rise of functional programming style in C++, boost::lambda pushes it so far (at the time it was created) that it supports a reasonably wide set of functional constructs with pure library approach in C++.
And then as I know from the news group, the author of boost::lambda and boost::phoenix try to combine the two libraries as they deal with virtually the same problem. I guess that was the beautifully designed boost::phoenix2
And then there comes boost::proto, which is a libary for writing expression templates, or I'd say it's a meta-library. So the phoenix nirvana again, reborn itself on boost::proto, then we see phoenix3. I think phoenix3 is the most powerful among all above.
On the other hand, C++11 adds language support for lambda expression, which I personally find very useful and handy. The only drawback is it's not polymorphic (while phoenix3 allows creating polymorphic function objects).
As a conclusion that I come with personal experience, C++11 lambda expression is the choice for daily job, if available. It's handy, clear and compile-time friendly. Phoenix3 is polymophic, very powerful, very cool, with the drawback of long compile-time.
But, if anyone can explain this with examples it would be great.
Examples of what? They're different implementations of the same concept.
Here's what's actually important:
boost::lambda::bind
along with that).boost::bind
is going to be replaced with that of boost::phoenix::bind
in the future. The only reason it hasn't been replaced already is that boost::bind
supports/has workarounds for older (read: broken) compilers e.g. MSVC6, whereas Boost.Phoenix strictly requires a C++03-compliant compiler.Combine these two facts and it becomes clear that the only real candidate for use in new code is boost::phoenix::bind
.
Also is it true that boost::phoenix is a superset of boost::bind, booost::lambda libraries?
Yes, this is correct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With