I have a bunch of boost::packaged_task<unsigned long>, which I intend
to execute on separate boost::threads. Before I do that, though, I
want to insert each boost::unique_future<unsigned long> in a container
as I make them. Given that I am using C++03 and boost 1.47.0 (boost
1.48.0 craps out over an ambiguous overload of boost::move), I have
something like the following:
std::deque futures;
// std::dequeboost::thread evalThreads; TODO
for (…) {
boost::packaged_task<unsigned long> task = …; // Create the tasks, one
at a time
boost::unique_future<unsigned long> taskResult = task.get_future();
// boost::thread taskThread(boost::move(task)); TODO
// boost::unique_future and boost::thread can't be copied, but can be moved
futures.push_back(boost::move(taskResult));
// evalThreads.push_back(boost::move(taskThread)); TODO
}
boost::wait_for_all(futures.begin(), futures.end());
// Now we can do stuff with futures
The problem is that the code above is failing to compile, saying that
/usr/include/c++/4.1.2/ext/new_allocator.h:104: error: passing ‘const
boost::unique_future<long unsigned int>’ as ‘this’ argument of
‘boost::unique_future<R>::operator
boost::detail::thread_move_t() [with R = long
unsigned int]’ discards qualifiers
I don't fully understand the problem, but I blame the move emulation.
How do I fix this?