c++ - Boost bind return type difference -


i have looked through discussion on what return type of boost::bind? , see short answer don't need know.

while have function taking "bind(...) result" argument , find following difference behaviour

working case 1

   void func(int a){};    myfunc(bind(&obj::func,this,_1)); 

not working case 2 ( when want bind func2 2 argument)

   void func2(int a, int b){};    myfunc(bind(&obj::func2,this,_1,_2)); 

made working case 3

   void func3(int a, int b){};    myfunc(bind(&obj::func3,this,_1, 10));      

so question what's differnt on retrun type of following 3?

bind(&obj::func,this,_1)); bind(&obj::func2,this,_1,10)); //why 1 can passed same type above one? bind(&obj::func3,this,_1,_2)); 

as myfunc quite embedded in template , overloading functions, didn't yet find how defined take "bind(...)" argument. that's why didn't attach code myfunc

as answer linked says, don't need know exact return type. type, however, compatible boost::function, can (as simplest example void(void)):

typedef boost::function<void(void)> myfunctiontype;  // function want bind void foo(){} // function should take argument void myotherfunction(myfunctiontype f); <...> // how bind myfunctiontype bar = boost::bind(foo); // , how pass argument myotherfunction(bar); 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -