vendredi 10 mars 2017

C++ thread error: no type named ‘type’

i know that this topic was asked a lot of time but I don't understand where is the error in my code.

I have a foo.h file where I have defined:

class Foo {
    public:
       Foo();
       ~Foo();
       void DoSomething(cv::Mat& img);
       void DoSomethingAsync(cv::Mat& img);

    private:
       bool isFinished = false;
};

then a foo.cpp like this:

Foo:Foo() {}

Foo:~Foo() {}

void Foo::DoSomethingAsync(cv::Mat& img) {
try {
    IsFinished = true;
} catch(exception& e) {
}   

void Foo::DoSomething(cv::Mat& img) {
 thread_mutex.lock();
 thread_async = std::move(std::thread(&Foo::DoSomethingAsync, this, img));
thread_mutex.unlock();
}

from my main.cpp file I call the function:

Foo foo;
foo.Detect(im);

when I compile, I always obtain this error:

error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void (ObjectDetector::*)(cv::Mat&)>(ObjectDetector*, cv::Mat)>’
   typedef typename result_of<_Callable(_Args...)>::type result_type;
                                                         ^
/usr/include/c++/5/functional:1526:9: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void (ObjectDetector::*)(cv::Mat&)>(ObjectDetector*, cv::Mat)>’
     _M_invoke(_Index_tuple<_Indices...>)

Could you explain me why?

in my CMake I set the variable CMAKE_CXX_FLAGS with -pthread

Aucun commentaire:

Enregistrer un commentaire