#include <iostream>
#include <string>
#include <thread>
#include <future>
#include <chrono>
int main()
{
auto pms = std::promise<std::string>();
auto ftr = pms.get_future();
std::thread thread([&](){pms.set_value("hello world");});
ftr.wait();
std::cout << ftr.get() << std::endl;
thread.join ();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dGhyZWFkPgojaW5jbHVkZSA8ZnV0dXJlPgojaW5jbHVkZSA8Y2hyb25vPgoKCmludCBtYWluKCkKewogICAgYXV0byBwbXMgPSBzdGQ6OnByb21pc2U8c3RkOjpzdHJpbmc+KCk7CiAgICBhdXRvIGZ0ciA9IHBtcy5nZXRfZnV0dXJlKCk7CgogICAgc3RkOjp0aHJlYWQgdGhyZWFkKFsmXSgpe3Btcy5zZXRfdmFsdWUoImhlbGxvIHdvcmxkIik7fSk7ICAgIAogICAgZnRyLndhaXQoKTsKICAgIHN0ZDo6Y291dCA8PCBmdHIuZ2V0KCkgPDwgc3RkOjplbmRsOwogICAgdGhyZWFkLmpvaW4gKCk7CiAgICByZXR1cm4gMDsKfQ==