尝试编译以下示例g++ -std=gnu++0x t1.cpp
,g++ -std=c++0x t1.cpp
但这两个结果都导致示例中止.
$ ./a.out
terminate called after throwing an instance of 'std::system_error'
what():
Aborted
Run Code Online (Sandbox Code Playgroud)
这是样本:
#include <thread>
#include <iostream>
void doSomeWork( void )
{
std::cout << "hello from thread..." << std::endl;
return;
}
int main( int argc, char *argv[] )
{
std::thread t( doSomeWork );
t.join();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我在Ubuntu 11.04上尝试这个:
$ g++ --version
g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
Run Code Online (Sandbox Code Playgroud)
谁知道我错过了什么?