Typedef rejected when disambiguating a call to boost::assign
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
On 30-10-2012 09:38, mark pashley wrote:
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.
I don't see how a typedef can change the code. Very wierd. Does it happen with other compilers? -Thorsten
Not had a chance to try it on any other compilers yet ( I haven't got
anything else available at work).
Here is the entire example if anyone is interested in trying it on another
compiler...
#include <set>
#include <map>
#include <algorithm>
#include <iterator>
#include
( 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) ) ;
int main( int, char** ) { the_map_t::const_iterator iter = data.begin(); the_map_t::const_iterator fin = data.end(); for (; iter != fin; ++iter ) { std::cout << "Index: " << iter->first << " { "; std::copy( iter->second.begin(), iter->second.end(), std::ostream_iterator<unsigned>( std::cout, " " ) ); std::cout << "}\n"; } return 0; } -- 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.
On 30-10-2012 11:20, mark pashley wrote:
Not had a chance to try it on any other compilers yet ( I haven't got anything else available at work).
Here is the entire example if anyone is interested in trying it on another compiler...
you store unsigned int in your container, but use signed int in list_of. Could that interfere? Could you try to use u suffix on the literals? (or the first literal in each list_of expression, because this is where the type is deduced) -Thorsten
Hi, I don't think the signed / unsignedness of the values is the problem, tried changing the_map_t data = boost::assign::map_list_of< uint32_t, the_set_t > > // bad line ( 1, boost::assign::list_of(10)(20)(30) ) to the_map_t data = boost::assign::map_list_of< uint32_t, the_set_t > > // bad line ( 1, boost::assign::list_of(10U)(20U)(30U) ) but it makes no difference. Regards Mark -- 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.
I could compile this with vc 2008 -Thorsten void test() { typedef std::set< unsigned > the_set_t; typedef std::map< unsigned, the_set_t > the_map_t; the_map_t data = boost::assign::map_list_of< unsigned, the_set_t > ( 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) ) ; the_map_t::const_iterator iter = data.begin(); the_map_t::const_iterator fin = data.end(); for (; iter != fin; ++iter ) { std::cout << "Index: " << iter->first << " { "; std::copy( iter->second.begin(), iter->second.end(), std::ostream_iterator<unsigned>( std::cout, " " ) ); std::cout << "}\n"; } return; }
participants (2)
-
mark pashley
-
Thorsten Ottosen