I have been working on a rather simple facility: a concurrent for
loop construct that takes a list of input elements, an output vector, and a function that computes output elements out of input elements.
I have this snippet that does not compile:
template<class In, class Out>
void thread_do(net::coderodde::concurrent::queue<In>& input_queue,
Out (*process)(In in),
std::vector<Out>& output_vector)
{
// Pop the queue, process, and save result.
...
}
for (unsigned i = 0; i < thread_count; ++i)
{
thread_vector.push_back(std::thread(thread_do,
input_queue,
process,
output_vector));
}
I use -std=c++14
.
./concurrent.h:129:45: error: no matching constructor for initialization of 'std::thread' thread_vector.push_back(std::thread(thread_do, ^ ~~~~~~~~~~
However, I have no idea how to fix it. Tried to prepend &
to the thread_do
/appending <In, Out>
, yet no to avail.