我整理了以下程序,但我不知道爲什麼我收到以下錯誤:中無法識別的命令行C++ 11
error: unrecognized command line option ‘-std=c++11’.
我的gcc版本是4.6,我已經設置C在NetBeans ++編譯器到C++ 11。
#include <cstdlib>
#include <algorithm>
using namespace std;
template<class T>
void parallel_sort(T* data, int len, int grainsize)
{
if(len < grainsize) // Use grainsize instead of thread count so that we don't e.g. spawn 4 threads just to sort 8 elements.
{
std::sort(data, data + len, std::less<T>());
}
else
{
parallel_sort(data + len/2, len/2, grainsize); // No need to spawn another thread just to block the calling thread which would do nothing.
std::inplace_merge(data, data + len/2, data + len, std::less<T>());
}
}
int main(int argc, char** argv) {
return 0;
}
嘗試'-std = C++ 0x',gcc4.6可能是太老了,支持'-std = C++ 11' – Praetorian
嘗試使用-std = C++ 0x – Sarang
我相信4.7.1左右添加了它。 – chris