I am trying to initialise a std::map of std::set using boost::assign, as
follows:
typedef std::set< uint32_t > the_set_t;
typedef std::map< uint32_t, the_set_t > the_map_t;
the_map_t data = boost::assign::map_list_of< uint32_t, the_set_t > > //
bad line
( 1, boost::assign::list_of(10)(20)(30) )
Unfortunately this is rejected by GCC 4.4.6, and results in a large amount
of errors, (attached below).
The problem is caused by the use of the typedef the_set_t. If the typedef is
replaced with std::set the code compiles and works correctly.
the_map_t data = boost::assign::map_list_of< uint32_t, std::set<
uint32_t > >
The error produced is as follows:
map-assign.cpp:19: error: conversion from ‘bool’ to non-scalar type
‘the_map_t’ requested
In file included from /opt/boost_1_51_0/boost/assign/list_of.hpp:397,
from map-assign.cpp:7:
/opt/boost_1_51_0/boost/preprocessor/iteration/detail/local.hpp:
In member function ‘boost::assign_detail::generic_list<T>&
boost::assign_detail::generic_list<T>::operator()
(const U&, const U0&) [with U = int, U0 =
boost::assign_detail::generic_list<int>, T = int]’:
map-assign.cpp:17: instantiated from here
/opt/boost_1_51_0/boost/preprocessor/iteration/detail/local.hpp:37:
error: functional cast expression list treated as compound expression
In file included from
/opt/boost_1_51_0/boost/iterator/iterator_categories.hpp:15,
from
/opt/boost_1_51_0/boost/iterator/detail/facade_iterator_category.hpp:7,
from
/opt/boost_1_51_0/boost/iterator/iterator_facade.hpp:14,
from
/opt/boost_1_51_0/boost/range/iterator_range_core.hpp:23,
from /opt/boost_1_51_0/boost/range/iterator_range.hpp:13,
from /opt/boost_1_51_0/boost/assign/list_of.hpp:20,
from map-assign.cpp:7:
/opt/boost_1_51_0/boost/mpl/eval_if.hpp: At global scope:
/opt/boost_1_51_0/boost/mpl/eval_if.hpp: In instantiation of
‘boost::mpl::eval_if_c, std::allocator<unsigned int> > > >
(const unsigned int&,
const std::set&)>,
boost::range_mutable_iterator<
boost::assign_detail::generic_list<
std::pair, std::allocator<unsigned int> > > >
(const unsigned int&,
const std::set&)> >’:
/opt/boost_1_51_0/boost/range/iterator.hpp:63: instantiated from
‘boost::range_iterator<
boost::assign_detail::generic_list<
std::pair,
std::allocator<unsigned int> > > >
(const unsigned int&, const std::set&)>’
/opt/boost_1_51_0/boost/range/iterator_range_core.hpp:72: instantiated
from
‘bool boost::iterator_range_detail::less_than(const Left&, const Right&)
[with Left = boost::assign_detail::converter<
boost::assign_detail::generic_list<int>,
std::_Deque_iterator >,
Right = boost::assign_detail::generic_list<
std::pair, std::allocator<unsigned int> > > >
(const unsigned int&, const std::set&)]’
/opt/boost_1_51_0/boost/assign/list_of.hpp:274: instantiated from
‘bool boost::assign_detail::operator<(const
boost::assign_detail::converter&, const Range&)
[with T = boost::assign_detail::generic_list<int>,
I = std::_Deque_iterator,
Range = boost::assign_detail::generic_list<
std::pair, std::allocator<unsigned int> > > >
(const unsigned int&, const std::set&)]’
/opt/boost_1_51_0/boost/assign/list_of.hpp:292: instantiated from
‘bool boost::assign_detail::operator>(const Range&, const
boost::assign_detail::converter&)
[with T = boost::assign_detail::generic_list<int>,
I = std::_Deque_iterator,
Range = boost::assign_detail::generic_list<
std::pair, std::allocator<unsigned int> > > >
(const unsigned int&, const std::set&)]’
map-assign.cpp:19: instantiated from here
/opt/boost_1_51_0/boost/mpl/eval_if.hpp:60:
error: no type named ‘type’ in ‘struct boost::range_mutable_iterator<
boost::assign_detail::generic_list<
std::pair,
std::allocator<unsigned int> > > >
(const unsigned int&, const std::set&)>’
In file included from /opt/boost_1_51_0/boost/range/iterator_range.hpp:13,
from /opt/boost_1_51_0/boost/assign/list_of.hpp:20,
from map-assign.cpp:7:
/opt/boost_1_51_0/boost/range/iterator_range_core.hpp:
In function ‘bool boost::iterator_range_detail::less_than(const Left&,
const Right&)
[with Left =
boost::assign_detail::converterboost::assign_detail::generic_list<int,
std::_Deque_iterator >,
Right =
boost::assign_detail::generic_list,
std::allocator<unsigned int> > > >
(const unsigned int&, const std::set&)]’:
/opt/boost_1_51_0/boost/assign/list_of.hpp:274: instantiated from
‘bool boost::assign_detail::operator<(const
boost::assign_detail::converter&, const Range&)
[with T = boost::assign_detail::generic_list<int>,
I = std::_Deque_iterator,
Range = boost::assign_detail::generic_list<
std::pair, std::allocator<unsigned int> > > >
(const unsigned int&, const std::set&)]’
/opt/boost_1_51_0/boost/assign/list_of.hpp:292: instantiated from
‘bool boost::assign_detail::operator>(const Range&, const
boost::assign_detail::converter&)
[with T = boost::assign_detail::generic_list<int>,
I = std::_Deque_iterator,
Range = boost::assign_detail::generic_list,
std::allocator<unsigned int> > > >
(const unsigned int&, const std::set&)]’
map-assign.cpp:19: instantiated from here
/opt/boost_1_51_0/boost/range/iterator_range_core.hpp:72: error: no matching
function for call to
‘begin(boost::assign_detail::generic_list<
std::pair, std::allocator<unsigned int> > > > (&)
(const unsigned int&, const std::set&))’
/opt/boost_1_51_0/boost/range/iterator_range_core.hpp:72: error: no matching
function for call to
‘end(boost::assign_detail::generic_list<
std::pair, std::allocator<unsigned int> > > > (&)
(const unsigned int&, const std::set&))’
In file included from map-assign.cpp:7:
/opt/boost_1_51_0/boost/assign/list_of.hpp: In member function
‘Container boost::assign_detail::converter::convert(
const Container*, boost::assign_detail::default_type_tag) const
[with Container = int,
DerivedTAssign = boost::assign_detail::generic_list<int>,
Iterator = std::_Deque_iterator]’:
/opt/boost_1_51_0/boost/assign/list_of.hpp:142: instantiated from
‘Container boost::assign_detail::converter::convert_to_container() const
[with Container = int, DerivedTAssign =
boost::assign_detail::generic_list<int>, Iterator =
std::_Deque_iterator]’
/opt/boost_1_51_0/boost/assign/list_of.hpp:436: instantiated from
‘boost::assign_detail::generic_list<T>::operator Container() const [with
Container = int, T = int]’
/opt/boost_1_51_0/boost/preprocessor/iteration/detail/local.hpp:37:
instantiated from
‘boost::assign_detail::generic_list<T>&
boost::assign_detail::generic_list<T>::operator()(const U&, const
U0&)
[with U = int, U1 = boost::assign_detail::generic_list<int>, T =
int]’
map-assign.cpp:17: instantiated from here
/opt/boost_1_51_0/boost/assign/list_of.hpp:163: error: functional cast
expression list treated as compound expression
/opt/boost_1_51_0/boost/assign/list_of.hpp:163: error: invalid cast from
type ‘std::_Deque_iterator’ to type ‘int’
What is wrong with using a typedef or is this a known limitation of
`boost::assign`?
--
View this message in context: http://boost.2283326.n4.nabble.com/Typedef-rejected-when-disambiguating-a-ca...
Sent from the Boost - Users mailing list archive at Nabble.com.