Добрый день.
Ubuntu 16.04 LTS х32, Netbeans, g++ - по умолчанию.
Пишу код:
#include <iostream>
#include <thread>
#include <future>
#include <functional>
using namespace std;
void aaa() {
std::packaged_task<int(int, int) > sss([](int a, int b) {
return a + b;
});
//std::thread tre(std::move(sss), 2, 10);
}
int main(int argc, char** argv) {
std::packaged_task<void() > t([]() {
std::cout << "worked";
});
std::future<void> result = t.get_future();
t();
result.get();
cout << "yes";
return 0;
}
Получаю вывод:
terminate called after throwing an instance of 'std::system_error'
what(): Unknown error -1
Раскоментируйте строку - std::thread tre(std::move(sss), 2, 10);
Получите вывод:
workedyes
Как невызываемая функция может влиять на результат?