问题描述本身非常简单。我正在测试C++ 11和boost :: thread库中std :: thread库的差异。为什么使用std :: thread :: hardware_concurrency()和boost :: thread :: hardware_concurrency()会有区别?
这些输出:
#include <iostream>
#include <thread>
#include <boost/thread.hpp>
int main() {
std::cout << std::thread::hardware_concurrency() << std::endl;
std::cout << boost::thread::hardware_concurrency() << std::endl;
return 0;
}
给了我不同的结果:
0
4
这是为什么?
PS:gcc软件包的版本是4.6.2-1.fc16(x86_64)。我使用
g++ test.cc -Wall -std=c++0x -lboost_thread-mt -lpthread
但实际上boost :: thread可以显示正确的信息4,而C++ 11给我0 ... – derekhh 2011-12-16 21:38:15