Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Boost::bind and Boost Phoenix::bind?

What is the difference between Boost::bind and Boost Phoenix::bind?

like image 629
Leandro Lima Avatar asked Aug 14 '09 14:08

Leandro Lima


People also ask

What does boost :: bind do?

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.

What is boost Phoenix?

Boost. Phoenix supports functional programming with function objects: Functions are objects based on classes which overload the operator operator() . That way function objects behave like other objects in C++. For example, they can be copied and stored in a container.

What is _1 in boost :: bind?

_1 is a placeholder. Boost. Bind defines placeholders from _1 to _9 . These placeholders tell boost::bind() to return a function object that expects as many parameters as the placeholder with the greatest number.

What are boost placeholders?

The placeholders provide std::bind compatible placeholders that additionally provide basic C++ operators that creates bind expressions. Each bind expression supports constexpr function evaluation.


1 Answers

phoenix::bind is like lambda::bind a function that returns an expression template that records that it has to call the given function. These are designed to work together with phoenix and lambda, respectively. As a result, they contain much more things. Like, the type they return overloads all possible operators so that their respective action can be recorded and executed later.

boost::bind is "just" a binder. It will bind the function, and return a type that has the function call operator overloaded, and not much more.

like image 70
Johannes Schaub - litb Avatar answered Oct 15 '22 17:10

Johannes Schaub - litb