using boost::assign with a std::set nested inside a std::map

boost, c++

Solution

In this case `boost::assign::map_list_of` needs a hint for second template argument - `<uint32_t, std::set< uint32_t> >`. Therefore line

the_map_t data = boost::assign::map_list_of(...);

becomes

the_map_t data = boost::assign::map_list_of<uint32_t, std::set< uint32_t> >(...);

Problem

I am trying to use `boost::assign` to emulate C++11 initialization of a `std::map` containing a `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) ); ``` Initialisation of `std::set` using `boost::assign::list_of` works as expected when used on its own, but when I try the above code the assignment is ambiguous at the point where the `std::set`'s constructor is called: ``` 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>] ``` How can I resolve this ambiguity error?

Original source