
13 Feb
2006
13 Feb
'06
11:28 p.m.
Sean Rhea wrote:
Hello,
Can someone please tell me why this doesn't work?
#include
#include #include using namespace std; using namespace boost;
struct MyClass { int i; void foo(int j){ printf("%d, %d\n", i, j); } function
bar() { return bind<void>(&MyClass::foo, this); } };
Unlike some other libraries, bind does not automatically append incoming arguments to the call; if you say bind( f, 5 ), it calls f( 5 ), regardless of how many input arguments are supplied. If you want the first input argument to be passed to MyClass::foo, you need to mention it explicitly, using _1: bind( &MyClass::foo, this, _1 )