Suppose an API requests, that a function f must have the signature void function(). Does the following code sample satisfy this requirements?
void func(int i)
{
do_something(i);
}
int main(int argc, char* argv[])
{
int i = 3;
auto f = boost::bind(func, i);
}
With other words: does f in this case meets the requirements of the given API?
EDIT: My question was a bit vague on the term "function". For clarification: f shall be function-like, so a simple function or a function object. The concrete case why I was asking this question came up, when I worked with strands in Boost.ASIO. Here, the documentation says for a possible handler for strand::post:
The function object to be called. The executor will make a copy of the handler object as required. The function signature of the function object must be:
void function();
So: is f from the above example a function object with the correct signature for strand::post?
Yes, the functor returned by
std::bindis a valid functor toio_service::strand::post.std::bindexists for such purposes, it binds paramaters with values and reduces its count to satisfy requirements of API.