У меня есть очень простой фрагмент кода от cpprefernce.com:
#include<future>
#include<iostream>
using namespace std;
int main(){
packaged_task<int(int)> t([](int i){return i+1;});
auto f = t.get_future();
cout<<"begin to call t\n";
t(3);
cout<<f.get()<<endl;
return 0;
}
Когда я запускаю его с g ++ на ubuntu18.04, он печатает:
begin to call t
terminate called after throwing an instance of 'std::system_error'
what(): Unknown error -1
Aborted
Так где же программа ошибается, как это исправить?