samedi 28 décembre 2019

Why following callable function gives compilation error while calling with C++11 thread object?

I got following error on VS2017:

Error   C2672   'std::invoke': no matching overloaded function found
Error   C2893   Failed to specialize function template 'unknown-type std::invoke(_Callable &&,_Types &&...) noexcept(<expr>)'

When I execute following code:

thread t2(do_customized_work, 5);

Follwoing is callable function:

void do_customized_work(int count)
{
    for (int i = 0; i < count; i++)
    {
        cout << i << endl;
        this_thread::sleep_for(0.1s);
    }
}

Aucun commentaire:

Enregistrer un commentaire