如何通过boost线程调用函数指针

时间:2015-02-05 05:47:07

标签: c++ boost boost-thread

class A { public: int xx(int size) { } public: int xx(int size) { } int yy(int size) { } }; int main() { typedef int (A::*functions)(int); std::vector<functions> methods = { &A::xx, &A::yy }; A aa; boost::thread_group thgrp; for (typename std::vector<functions>::iterator itr=methods.begin();itr!=methods.end();++itr) { functions z=*itr; boost::thread *t=new boost::thread(z,aa,10); thgrp.add_thread(t); } thgrp.join_all(); return 0; }

我收到错误“没有匹配函数来调用'get_pointer'”。 我想使用boost thread从我预定义类型的向量中调用方法。

请帮我解决这个问题!

1 个答案:

答案 0 :(得分:0)

对不起!!!

我发现了我的错误!这段代码工作正常!
我使用对象“methods”调用boost :: thread,而不是将对象调用到类“aa”。

相关问题