Boost logo

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&lt;
            boost::assign_detail::generic_list&lt;
                std::pair&lt;unsigned int,
                          std::set&lt;unsigned int, std::less&lt;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&lt;unsigned int, std::less&lt;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&lt;unsigned int, std::less&lt;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&amp;, int*> >,
              Right = boost::assign_detail::generic_list<
                          std::pair<unsigned int, std::set&lt;unsigned int,
std::less&lt;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&amp;, int*>,
              Range = boost::assign_detail::generic_list<
                          std::pair<unsigned int,
                                   std::set&lt;unsigned int,
std::less&lt;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&amp;, int*>,
              Range = boost::assign_detail::generic_list<
                          std::pair<unsigned int,
                                    std::set&lt;unsigned int,
std::less&lt;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&lt;unsigned int, std::less&lt;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&lt;int>,
                   std::_Deque_iterator<int, int&amp;, int*> >,
              Right =
boost::assign_detail::generic_list<std::pair&lt;unsigned int,
                   std::set&lt;unsigned int, std::less&lt;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&amp;, int*>,
          Range = boost::assign_detail::generic_list<
              std::pair<unsigned int,
                        std::set&lt;unsigned int, std::less&lt;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&amp;, int*>,
          Range = boost::assign_detail::generic_list<std::pair&lt;unsigned
int, std::set&lt;unsigned int, std::less&lt;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&lt;unsigned int,
std::less&lt;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&lt;unsigned int,
std::less&lt;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&amp;, 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&amp;, 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&amp;, 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