dimanche 10 mai 2015

Using cpp11 thread to run a member function as a thread

I'm trying to run an object member function as a thread using c++11 threads. This is the function:

void FilterRun::runThreadFront(Mat* image, int num){
    std::thread t1(std::bind(&FilterRun::runFrontCameraThread, this, image, num));
}

FilterRun is the class, and runFrontCameraThread is the function I want to run. image and num are the two parameters that runFrontCamera receives. This throws me this error:

../src/FilterRun.cpp:375:78:   required from here
/usr/include/c++/4.8/functional:1697:61: error: no type named ‘type’ in ‘class std::result_of<std::_Bind<std::_Mem_fn<void (FilterRun::*)(cv::Mat&, int)>(FilterRun*, cv::Mat*, int)>()>’
       typedef typename result_of<_Callable(_Args...)>::type result_type;
                                                             ^
/usr/include/c++/4.8/functional:1727:9: error: no type named ‘type’ in ‘class std::result_of<std::_Bind<std::_Mem_fn<void (FilterRun::*)(cv::Mat&, int)>(FilterRun*, cv::Mat*, int)>()>’
         _M_invoke(_Index_tuple<_Indices...>)
         ^
make: *** [src/FilterRun.o] Error 1 

Any thoughts?

Aucun commentaire:

Enregistrer un commentaire