Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22011

Destructor of a future in async C++11

$
0
0

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()??


Viewing all articles
Browse latest Browse all 22011

Trending Articles