我得到試圖編譯下面的代碼時出錯:的boost ::承諾:: set_exception()編譯錯誤
#include <exception>
#include <boost/thread.hpp>
int _tmain(int argc, _TCHAR* argv[])
{
boost::promise<int> pr;
pr.set_exception(std::copy_exception(std::runtime_error("test")));
std::cout << "done" << std::endl;
}
錯誤C2668: '提高:: copy_exception':曖昧通話重載函數d:\項目\提升\ boost_1_55_0 \提升\螺紋\ future.hpp 2092
我使用VS2010和Boost 1.55
對於參考:`的boost ::承諾的實現: :set_exception'如下:
void set_exception(boost::exception_ptr p)
{
// exception is stored here
}
template <typename E> void set_exception(E ex)
{
set_exception(copy_exception(ex)); // <- this is the line 2092
}
所以,有一個模板版本,它調用非模板版本。 我假設在我的情況下模板版本失敗。
問題消失時,用下面的代碼:
pr.set_exception(boost::copy_exception(std::runtime_error("test")));
即boost::copy_exception()
代替std::copy_exception()
。
任何人都可以建議使用std::copy_exception
編譯代碼的選項嗎?
我不知道這是否相關:http://stackoverflow.com/questions/37831458/where-is-stdcopy-exception-defined –