मैं बस जीसीसी 4.7.2 के साथ नई सी ++ 11 सुविधाओं में से कुछ कोशिश कर रहा हूं, हालांकि जब मैं एक सीजी गलती चलाने के लिए जाता हूं।सी ++ 11 Async seg गलती
$ ./a.out
Message from main.
terminate called after throwing an instance of 'std::system_error'
what(): Unknown error -1
Aborted (core dumped)
मैं ग के संबंध में जीसीसी के 'बीटा' सुविधाओं के साथ संकलित, ++ 0x के साथ:
g++ -std=c++11 c11.cpp
कोड:
#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;
}
+1। आपको बहुत - बहुत धन्यवाद! – TheBlueCat
एफडब्ल्यूआईडब्ल्यू, जोड़ना-अकेलापन अकेले काम नहीं करता था, लेकिन -छाई ने किया। –