|
Boost Users : |
Subject: [Boost-users] Typedef rejected when disambiguating a call to boost::assign
From: mark pashley (mark.pashley_at_[hidden])
Date: 2012-10-30 04:38:14
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<uint32_t> 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<false,
boost::range_const_iterator<
boost::assign_detail::generic_list<
std::pair<unsigned int,
std::set<unsigned int, std::less<unsigned
int>, std::allocator<unsigned int> > > >
(const unsigned int&,
const std::set<unsigned int, std::less<unsigned int>,
std::allocator<unsigned int> >&)>,
boost::range_mutable_iterator<
boost::assign_detail::generic_list<
std::pair<unsigned int,
std::set<unsigned int, std::less<unsigned
int>, std::allocator<unsigned int> > > >
(const unsigned int&,
const std::set<unsigned int, std::less<unsigned int>,
std::allocator<unsigned int> >&)> >â:
/opt/boost_1_51_0/boost/range/iterator.hpp:63: instantiated from
âboost::range_iterator<
boost::assign_detail::generic_list<
std::pair<unsigned int,
std::set<unsigned int, std::less<unsigned int>,
std::allocator<unsigned int> > > >
(const unsigned int&, const std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> >&)>â
/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<int, int&, int*> >,
Right = boost::assign_detail::generic_list<
std::pair<unsigned int, std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> > > >
(const unsigned int&, const std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> >&)]â
/opt/boost_1_51_0/boost/assign/list_of.hpp:274: instantiated from
âbool boost::assign_detail::operator<(const
boost::assign_detail::converter<T, I>&, const Range&)
[with T = boost::assign_detail::generic_list<int>,
I = std::_Deque_iterator<int, int&, int*>,
Range = boost::assign_detail::generic_list<
std::pair<unsigned int,
std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> > > >
(const unsigned int&, const std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> >&)]â
/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<T, I>&)
[with T = boost::assign_detail::generic_list<int>,
I = std::_Deque_iterator<int, int&, int*>,
Range = boost::assign_detail::generic_list<
std::pair<unsigned int,
std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> > > >
(const unsigned int&, const std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> >&)]â
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<unsigned int,
std::set<unsigned int, std::less<unsigned int>,
std::allocator<unsigned int> > > >
(const unsigned int&, const std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> >&)>â
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::converter<boost::assign_detail::generic_list<int>,
std::_Deque_iterator<int, int&, int*> >,
Right =
boost::assign_detail::generic_list<std::pair<unsigned int,
std::set<unsigned int, std::less<unsigned int>,
std::allocator<unsigned int> > > >
(const unsigned int&, const std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> >&)]â:
/opt/boost_1_51_0/boost/assign/list_of.hpp:274: instantiated from
âbool boost::assign_detail::operator<(const
boost::assign_detail::converter<T, I>&, const Range&)
[with T = boost::assign_detail::generic_list<int>,
I = std::_Deque_iterator<int, int&, int*>,
Range = boost::assign_detail::generic_list<
std::pair<unsigned int,
std::set<unsigned int, std::less<unsigned
int>, std::allocator<unsigned int> > > >
(const unsigned int&, const std::set<unsigned int, std::less<unsigned
int>, std::allocator<unsigned int> >&)]â
/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<T, I>&)
[with T = boost::assign_detail::generic_list<int>,
I = std::_Deque_iterator<int, int&, int*>,
Range = boost::assign_detail::generic_list<std::pair<unsigned
int, std::set<unsigned int, std::less<unsigned int>,
std::allocator<unsigned int> > > >
(const unsigned int&, const std::set<unsigned int, std::less<unsigned
int>, std::allocator<unsigned int> >&)]â
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<unsigned int, std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> > > > (&)
(const unsigned int&, const std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> >&))â
/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<unsigned int, std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> > > > (&)
(const unsigned int&, const std::set<unsigned int,
std::less<unsigned int>, std::allocator<unsigned int> >&))â
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<DerivedTAssign,
Iterator>::convert(
const Container*, boost::assign_detail::default_type_tag) const
[with Container = int,
DerivedTAssign = boost::assign_detail::generic_list<int>,
Iterator = std::_Deque_iterator<int, int&, int*>]â:
/opt/boost_1_51_0/boost/assign/list_of.hpp:142: instantiated from
âContainer boost::assign_detail::converter<DerivedTAssign,
Iterator>::convert_to_container() const
[with Container = int, DerivedTAssign =
boost::assign_detail::generic_list<int>, Iterator =
std::_Deque_iterator<int, int&, int*>]â
/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<int, int&, int*>â 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-call-to-boost-assign-tp4637775.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net