我正在尝试使用boost::assign
来模拟std::map
包含 a 的C++11 初始化std::set
。
#include <set>
#include <map>
#include <stdint.h>
#include <boost/assign/list_of.hpp>
typedef std::map< uint32_t, std::set< uint32_t> > the_map_t;
the_map_t data = boost::assign::map_list_of( 1, boost::assign::list_of(10)(20)(30) )
( 2, boost::assign::list_of(12)(22)(32) )
( 3, boost::assign::list_of(13)(23)(33) )
( 4, boost::assign::list_of(14)(24)(34) );
using的初始化在单独std::set
使用boost::assign::list_of
时按预期工作,但是当我尝试上面的代码时,分配在std::set
调用 's 的构造函数时是模棱两可的:
map-assign.cpp:16: instantiated from here
include/c++/4.4.6/bits/stl_pair.h:101: error: call of overloaded set(const boost::assign_detail::generic_list<int>&) is ambiguous
include/c++/4.4.6/bits/stl_set.h:188: note: candidates are:
std::set<_Key, _Compare, _Alloc>::set(
const std::set<_Key, _Compare, _Alloc>&)
[with _Key = unsigned int, _Compare = std::less<unsigned int>, _Alloc = std::allocator<unsigned int>]
include/c++/4.4.6/bits/stl_set.h:145: note:
std::set<_Key, _Compare, _Alloc>::set(
const _Compare&, const _Alloc&)
[with _Key = unsigned int, _Compare = std::less<unsigned int>, _Alloc = std::allocator<unsigned int>]
如何解决此歧义错误?