简体   繁体   English

没有匹配的函数来调用&#39;bind( <unresolved overloaded function type> ,const std :: _ Placeholder &lt;1&gt;&,int *)

[英]no matching function for call to ‘bind(<unresolved overloaded function type>, const std::_Placeholder<1>&, int*)

#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));
}

I cann't understand why? 我不明白为什么?

detail log: 详细日志:

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不是您需要提供template参数的函数名称:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有匹配的函数来调用&#39;std :: list <int, std::allocator<int> &gt; :: sort( <unresolved overloaded function type> )&#39; - No matching function for call to 'std::list<int, std::allocator<int> >::sort(<unresolved overloaded function type>)' 如何解决错误:“没有匹配的函数来调用&#39;bind( <unresolved overloaded function type> 在类中使用std :: bind时 - How to solve the error: “no matching function for call to ‘bind(<unresolved overloaded function type>” when std::bind is used in a class 没有用于调用std :: transform,未解析的重载函数类型的匹配函数 - No matching function for call to std::transform, unresolved overloaded function type ros编译错误。 错误:没有匹配的 function 调用 'ros::NodeHandle::subscribe(const char [16], int,<unresolved overloaded function type> )'</unresolved> - Ros compile error. Error: no matching function for call to ‘ros::NodeHandle::subscribe(const char [16], int, <unresolved overloaded function type>)’ 没有匹配的函数可调用未解析的重载函数类型 - No matching function for call to unresolved overloaded function type 没有匹配的 function 可以打电话给<unresolved overloaded function type></unresolved> - no matching function for call to <unresolved overloaded function type> 没有匹配的函数无法调用未解析的重载函数类型 - no matching function for call unresolved overloaded function type “没有匹配的函数可以调用...未解析的重载函数类型” - “No matching function for call to… unresolved overloaded function type” “没有匹配函数来调用'async(std :: launch,<unresolved overloaded function type>,std :: string&)'” - “no matching function for call to ‘async(std::launch, <unresolved overloaded function type>, std::string&)’” C++ 多线程错误:没有匹配的 function 调用 'std::thread::thread(<unresolved overloaded function type></unresolved> - C++ Multithreading Error : no matching function for call to 'std::thread::thread(<unresolved overloaded function type>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM