【发布时间】:2016-07-28 16:35:24
【问题描述】:
尝试编译以下代码时出现错误:
#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:'boost::copy_exception':对重载函数 d:\projects\boost\boost_1_55_0\boost\thread\future.hpp 2092 的模糊调用
我正在使用 VS2010 和 Boost 1.55
供参考:`boost::promise::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 编译代码的选项吗?
【问题讨论】:
-
我想知道这是否相关:stackoverflow.com/questions/37831458/…
标签: c++ boost boost-thread