So, I have this bit of code, which is supposed to be run as a separate thread:
template<class Iterator>
void thread_launcher(Iterator start, Iterator fin, size_t sort_type) {
// Blah blah
mixed_sort<less<int>>(start, fin, sort_type);
// blah blah
}
And this code is supposed to create this thread:
for (size_t sort_type = 2; sort_type!= 7; ++sort_type) {
// blah
t[sort_type] = thread(thread_launcher, copy.begin(), copy.end(), sort_type);
}
, where t is an array of thread.
The problem is --- when I try to compile this, I get this error:
main.cpp:245:32: error: no matching constructor for initialization of
'std::__1::thread'
...= thread(thread_launcher, copy.begin(), copy.end(), sort_type);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/http://ift.tt/YWy3MO: note:
candidate template ignored: couldn't infer template argument '_Fp'
thread::thread(_Fp&& __f, _Args&&... __args)
I don't understand what did I do wrong, though it's the first time I've ever worked with multithreading, let alone std::thread. What should I do to fix this?
Aucun commentaire:
Enregistrer un commentaire