🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
上篇博客《[c++11特性之std::thread–初识](http://blog.csdn.net/wangshubo1989/article/details/49592517 "std::thread")》初步介绍了std::thread,并且介绍了几个成员函数。 最后的一段代码留了点悬念,就是vs2015会报错,错误如下: ~~~ error C2893: 未能使函数模板“unknown-type std::invoke(_Callable &&,_Types &&...)”专用化 1> d:\program files (x86)\microsoft visual studio 14.0\vc\include\thr\xthread(238): note: 用下列模板参数: ... ========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ========== ~~~ 代码改为: ~~~ #include <iostream> #include <thread> using namespace std; class Foo { void bar_i() { cout << "hello" << endl; } public: void bar() { auto func = std::bind(&Foo::bar_i, this); std::thread t(&Foo::bar_i, this); t.join(); } }; int main() { Foo f; f.bar(); } ~~~ 至于原因呢?  在std::thread中,指向成员函数的指针知道第一个参数是引用。 哈哈 上面一句话太牵强了,好吧 我也不是真正的理解 请大神指点迷津、