I can’t make it std::bindwork the way it works boost::bind. Either I do not use it correctly, or my compiler (GCC 4.4.5) does not yet implement it correctly.
I have two functions:
void f(int x, int y)
{
cout << x << " | " << y << endl;
}
template <class UnaryFunction>
void g(UnaryFunction func)
{
func(100);
}
I use bind to call fas a unary function in g:
g(std::bind(f, 10, std::placeholders::_1));
The result is a compiler error:
error: no match for call to ‘(std::_Bind<void (*(int, std::_Placeholder<1>))(int, int)>) (int)’
... followed by a page or so, due to vomiting of the template compiler.
If I use boost::bind, for example:
g(boost::bind(f, 10, _1));
... it works great. Is semantics std::bindsomething else, or is it a compiler problem?
source
share