Question

I would like to know why my compiler complains when I test the following code :

int main(int argc, char**) {    
...
std::future<int> result( std::async([](int m, int n) { return m + n;} , 2, 4));
...
return 0;
}

It gives: error: ‘future’ is not a member of ‘std’

I have gcc (Ubuntu/Linaro 4.7.3-2ubuntu1~12.04) 4.7.3.

Thanks!

Était-ce utile?

La solution

You need to include the <future> header and switch on C++11 support with compiler flag -std=c++11.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top