
From: "Phil Nash" <phil.nash.lists@squareseven.com>
#include "stdafx.h" #include <boost\function.hpp> #include <boost\bind.hpp>
class MyClass { public: int MyMember(int,int,int); };
int MyClass::MyMember(int x,int y,int z) { int a = x + y + z; }
int main(int argc, char* argv[]) { MyClass mcl; boost::function3<int,int,int,int> bf; bf = boost::bind(&MyClass::MyMember,&mcl); bf(2,3,4); return 0; }
Yep, there it is... you need to tell bind the ordinal positions of each argument to bind to. Just rewrite the line that constructs bind something like this:
bf = boost::bind(&MyClass::MyMember,&mcl, _1, _2, _3);
...and it should work.
Yes. bind() requires that you supply exactly the number of arguments that is required by the function (object.) http://www.boost.org/libs/bind/bind.html#err_num_args