简体   繁体   中英

how to call a function pointer via 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; }

I'm getting an error "no matching function for call to 'get_pointer'". I want to call the methods from the vector of my predefined type using boost threads.

Please help me to solve this!

Sorry!!!

I found the mistake done by me! this code is working properly!
i called boost::thread with the object "methods" instead of the object to the class "aa".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM