Boost logo

Boost Users :

Subject: [Boost-users] BOOST_FOREACH and boost::bimap
From: Conoscenza Silente (abruzzoforteegentile_at_[hidden])
Date: 2009-11-27 03:08:47


Hi All
I tried to use BOOST_FOREACH with bimap but it doesn't compile.
What is wrong in using it the way is displayed below?
Reading the specs it should be able to work since bimap provide .begin() and
.end() methods.
Thanks
CS

typedef boost::bimap<int,std::string > BMap;
typedef boost::bimap<int,std::string >::value_type BMapVal;
typedef boost::bimap<int,std::string >::const_iterator BMapKIt;

BMap myBimap;

myBimap.insert( BMapVal( 10, "hi") );
myBimap.insert( BMapVal( 20, "hihihi") );

BOOST_FOREACH( BMapKIt it, myBimap) // this line doesnt' compile:
{
            std::cout << "LEFT: " << it->left
                        << " RIGHT: " << it->right << std::endl;
}

TestBoost_Nov26.h:68: error: conversion from
‘boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
int, boost::bimaps::relation::member_at::left>,
boost::bimaps::tags::tagged<const std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
boost::bimaps::relation::member_at::right>, mpl_::na, false>’ to non-scalar
type
‘boost::bimaps::detail::set_view_iterator<boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
int, boost::bimaps::relation::member_at::left>,
boost::bimaps::tags::tagged<const std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
boost::bimaps::relation::member_at::right>, mpl_::na, true>,
std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
int, boost::bimaps::relation::member_at::left>,
boost::bimaps::tags::tagged<const std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
boost::bimaps::relation::member_at::right>, mpl_::na, true> > > > > >’
requested



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