我正在尝试使用boost :: thread将C++ 11 std :: thread代码移植到VC9(VS 2008).下面的'等效'C++ 11代码在msvc12上编译得很好:
#include <iostream>
#include <thread>
#include <vector>
#include <algorithm>
#include <cassert>
void thFun(int i)
{
std::cout << "Hello from thread " << i << " !\n";
}
int main()
{
std::vector<std::thread> workers;
for (int i = 0; i < 10; ++i)
{
auto th = std::thread(&thFun, i);
workers.push_back(std::move(th));
assert(!th.joinable());
}
std::cout << "Hello from main!\n";
std::for_each(workers.begin(), workers.end(), [](std::thread& th)
{
assert(th.joinable());
th.join();
});
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我想使用msvc9编译器和Boost 1.55将代码移植到C++ 03.如何解决以下编译错误:
#include <iostream>
#include …Run Code Online (Sandbox Code Playgroud)