vendredi 26 juillet 2019

How do I properly pass this pointer to std::thread

ALL,

In myclass.cpp

MyClass::Initialize()
{
    m_thread = new std::thread( &Foo::func, *this );
}

In foo.cpp:

void Foo::func(MyClass &obj)
{
    // some processing
    // which involves modifying `obj`
}

I am getting a compiler error on gcc:

error: no type named 'type' in 'class std::result_of<std::_Mem_fn<void (Foo::*)(MyClass&)>(Foo*, MyClass)>'
       typedef typename result_of<_Callable(_Args...)>::type result_type;
                                                             ^

TIA!

Aucun commentaire:

Enregistrer un commentaire