Should not a compiler call the destructor of the future future
right after the main
finishes, that is, should not be the function f()
called anyway? (gcc 4.7.2 doesn't do that).
#include <iostream>#include <thread>#include <future>using namespace std;void f() { cout << "thread...\n";}int main() { auto future = async(&f); cout << "I am main\n";}
edit: I get onlyHello from main
. The text thread...
is NOT printed at all.
edit 2: Does the destructor of a future call wait()
??