Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-07-15 04:55:54


From: "Phil Nash" <phil.nash.lists_at_[hidden]>
> >
> > #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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net