没有用于调用 'bind(<未解析的重载函数类型>, const std::_Placeholder<1>&, int*) 的匹配函数

Pengcheng
#include <functional>

template <typename T>
void TemplateFunc(const int value, T* addr) {
}

void Register(std::function<void(const int)>&& callback) {
  callback(2);
}

int main() {
  int int_value;
  Register(std::bind(&TemplateFunc, std::placeholders::_1, &int_value));
}

我不明白为什么?

详细日志:

test.cpp: In function ‘int main()’:
test.cpp:13:70: error: no matching function for call to ‘bind(<unresolved overloaded function type>, const std::_Placeholder<1>&, int*)’
   Register(std::bind(&TemplateFunc, std::placeholders::_1, &int_value));

                                                                      ^
test.cpp:13:70: note: candidates are:
In file included from test.cpp:1:0:
/usr/local/gcc4.8.2/include/c++/4.8.2/functional:1655:5: note: template<class _Func, class ... _BoundArgs> typename std::_Bind_helper<std::__or_<std::is_integral<typename std::decay<_Tp>::type>, std::is_enum<typename std::decay<_Tp>::type> >::value, _Func, _BoundArgs ...>::type std::bind(_Func&&, _BoundArgs&& ...)
     bind(_Func&& __f, _BoundArgs&&... __args)
扬斯

TemplateFunc 不是您需要提供模板参数的函数名称:

Register(std::bind(&TemplateFunc<int>, std::placeholders::_1, &int_value));

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

错误:没有用于调用“std::vector<float>::push_back(std::vector<float>&) const”的匹配函数

没有匹配的函数可以调用'std :: less <int> :: less(const int&,const int&)'

错误:没有用于调用“std::vector<Movie>::erase(size_t&)”的匹配函数

没有匹配的函数调用std :: transform,未解析的重载函数类型

在Rcpp中没有用于调用“ as”的匹配函数

没有用于调用“类”的匹配函数

没有用于调用 stof 的匹配函数

线程C ++:没有用于调用的匹配函数

没有用于调用“currency::currency()”的匹配函数

错误:没有用于调用“CreateFileW”的匹配函数

“没有匹配的函数可以调用'async(std :: launch,<未解析的重载函数类型>,std :: string&)'”

'max'没有重载匹配'std :: function <const int&(const int&,const int&)>'

如何解决错误:在类中使用std :: bind时,“没有匹配的函数可用于对'bind(<unresolved的重载函数类型>的调用”

没有用于调用默认构造函数的匹配函数

构造函数中没有用于调用的匹配函数-C ++ 11

默认构造函数错误,没有用于调用的匹配函数

错误:没有用于调用“构造函数”的匹配函数注意:候选对象是:

在作为类“没有用于调用swap()的匹配函数”的成员的向量上调用sort()

错误:没有用于初始化“std::shared_ptr<uint8_t []>”的匹配构造函数

g++ 错误:没有用于调用“fpclassify(float&)”的匹配函数

没有用于调用“student::student()”错误的匹配函数

错误:没有用于调用“DollarAmount::DollarAmount(<brace-enclosed initializer list>)”的匹配函数

没有用于调用 Employee::Employee() 错误的匹配函数

没有用于调用“regex_match”的匹配函数

没有可变参数调用std :: forward(const std :: string&)的匹配函数

没有匹配的函数无法调用未解析的重载函数类型

构建幕府将军时出错:没有用于调用“PyUnicode_AsUTF8AndSize”的匹配函数

使用std :: bind与重载函数

没有用int调用的参数的字符串函数应该会失败构建