【发布时间】:2012-09-10 13:24:46
【问题描述】:
我正在尝试将项目从 VS2008 转换为 2010,但由于添加了移动构造函数而遇到了问题(并且可能是这里有嵌套的 list_of 的事实)。以下代码 sn-p 显示了错误(在实际代码中,这些构造用于初始化一些静态):
enum some_enum {R, G, B};
typedef std::pair<some_enum, some_enum> Enum_Pair;
typedef std::vector<some_enum> Enum_list;
typedef std::pair<Enum_Pair, Enum_list> Some_Struct;
typedef std::list<Some_Struct> Full_Struct;
#define MAKEFULLSTRUCT(First_, Second_, some_enums)\
(Some_Struct(Enum_Pair(First_, Second_), list_of (some_enums) ))
int main()
{
int i = G;
Full_Struct test_struct = list_of
MAKEFULLSTRUCT(R, R, R).to_container(test_struct);
}
导致
error C2668: 'std::vector<_Ty>::vector' : ambiguous call to overloaded function
with [_Ty=some_enum]
vector(593): could be 'std::vector<_Ty>::vector(std::vector<_Ty> &&)'
with [ _Ty=some_enum]
vector(515): or 'std::vector<_Ty>::vector(unsigned int)'
with [ _Ty=some_enum]
while trying to match the argument list '(boost::assign_detail::generic_list<T>)'
with [ T=some_enum ]
在使用 boost::list_of 的同时,有什么方法可以解决这个问题吗?还是我必须切换到另一种初始化机制?
【问题讨论】:
-
你使用什么版本的 boost?
标签: c++ visual-c++ boost compiler-errors