I'm just trying a few of the new C++11 features with GCC 4.7.2, though when I go to run a seg fault occurs.
$ ./a.out
Message from main.
terminate called after throwing an instance of 'std::system_error'
what(): Unknown error -1
Aborted (core dumped)
I compiled with the 'beta' features of GCC, in regards to c++0x with:
g++ -std=c++11 c11.cpp
The code:
#include <future>
#include <iostream>
void called_from_async() {
std::cout << "Async call" << std::endl;
}
int main() {
//called_from_async launched in a separate thread if possible
std::future<void> result( std::async(called_from_async));
std::cout << "Message from main." << std::endl;
//ensure that called_from_async is launched synchronously
//if it wasn't already launched
result.get();
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With