#include <iostream>
#include <thread>
using namespace std;
thread&& launch(){
thread launchee([](){
this_thread::sleep_for(chrono::milliseconds(280));
cout<<"HA!"<<endl;
});
return move(launchee);
}
int main(int argc, char **argv){
thread mine(launch());
mine.join();
}
与g++-4.6 -std=c++0x 1.cpp -o e1 -pthread
为什么这很简单返回std :: move(线程句柄)失败?
输出编译“终止叫不活跃异常”,然后程序中止。
这应该工作,不应该吗?
右值引用仍然是引用。你不想返回对局部变量的引用。 – bames53 2012-04-21 01:07:59