标签: boost-move

将C++ 11 std :: thread移植到boost :: thread编译问题

我正在尝试使用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)

c++ boost boost-thread visual-c++ boost-move

8
推荐指数
1
解决办法
689
查看次数

标签 统计

boost ×1

boost-move ×1

boost-thread ×1

c++ ×1

visual-c++ ×1