I am unsure why below code is throwing a runtime exception when run in online compiler here. I am trying to execute a function via packaged task
#include <iostream>
#include <future>
int display(int i)
{
std::cout << "In display";
return i + 1;
}
int main()
{
std::packaged_task<int(int)> pt(display);
auto fut = pt.get_future();
pt(5);
std::cout << "\n PT returns " << fut.get();
return 0;
}
The error which i am getting is
/tmp/RucY1KsPrS.o
terminate called after throwing an instance of 'std::system_error'
what(): Unknown error -1
Aborted