【发布时间】:2016-09-22 11:49:41
【问题描述】:
我查看了What is the return type of boost::bind? 上的讨论,简短的回答是您不需要知道。
虽然我有一个将“bind(...) result”作为参数的函数,但我发现以下不同的行为
工作案例 1
void func(int a){};
myfunc(bind(&obj::func,this,_1));
不工作情况 2(当我想用 2 个参数绑定 func2 时)
void func2(int a, int b){};
myfunc(bind(&obj::func2,this,_1,_2));
使其适用于案例 3
void func3(int a, int b){};
myfunc(bind(&obj::func3,this,_1, 10));
所以我的问题是以下 3 的重新运行类型有什么不同?
bind(&obj::func,this,_1));
bind(&obj::func2,this,_1,10)); //why this one can be passed the same type as above one?
bind(&obj::func3,this,_1,_2));
由于myfunc 是一个完全嵌入模板和重载函数的函数,我还没有找到它是如何定义为将“bind(...)”作为参数的。所以我没有附上myfunc的代码
【问题讨论】:
-
所以你真正的问题是
myfunc的参数应该是什么类型? -
@SingerOfTheFall ,通过了解bind的返回类型,我可以自己设计我认为想要的myfuc参数类型
-
你得到什么错误?
-
你明白
std::bind()实际上做了什么吗? -
“简短的回答是你不需要知道。”...