std::set
을 포함하는 std::map
의 C++ 11 초기화를 에뮬레이트하기 위해 boost::assign
을 사용하려고합니다. boost::assign::list_of
작품을 사용 std::set
의std :: map 내에서 중첩 된 std :: set으로 boost :: assign을 사용합니다.
#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));
초기화는 그 자체로 사용하는 경우 예상하지만 위의 코드를하려고 할 때 할당은 std::set
의 생성자가 호출되는 시점에서 모호 같이
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>]
어떻게이 모호성 오류를 해결할 수 있습니까?
전혀'LIST_OF (10U) (20U) (30U)'도움이됩니까된다? – aschepler