Я пытаюсь перехватить исключение «Уже получено», как показано на http://www.cplusplus.com/reference/future/future_errc/
try {
prom.get_future();
prom.get_future(); // throws std::future_error with future_already_retrieved
}
catch (std::future_error& e) {
if (e.code() == std::make_error_condition(std::future_errc::future_already_retrieved))
std::cerr << "[future already retrieved]\n";
else
std::cerr << "[unknown exception]\n";
}
Но я всегда получаю исключение без состояния. Глядя на будущую реализацию std:
_Ty& _Get_value() const
{ // return the stored result or throw stored exception
if (!valid()) // will check if already retrieved, and return false
_Throw_future_error(make_error_code(future_errc::no_state));
return (_Assoc_state->_Get_value(_Get_only_once)); // only this
// method can throw the already retrieved exception but its not
// being hit because of previous valid() check
}
Это ошибка в Visual Studio 2013 или функция?
std::promise
илиstd::packaged_task
(в частности, реализациюstd::promise::get_future
илиstd::packaged_task::get_future
), а не на реализациюstd::future
. - person cpplearner   schedule 18.09.2015