1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
// future::future
#include <iostream> // std::cout
#include <future> // std::async, std::future
int get_value() { return 10; }
int main ()
{
std::future<int> foo; // default-constructed
std::future<int> bar = std::async (get_value); // move-constructed
int x = bar.get();
std::cout << "value: " << x << '\n';
return 0;
}
|