C++: const_iterator not comparable to iterator for map<>s

Gerald Pfeifer pfeifer@dbai.tuwien.ac.at
Fri Nov 17 12:40:00 GMT 2000


The following snippet broke by the move to libstdc++-v3, while I think
it is legal code:

  #include <map>

  using namespace std;

  typedef map<int, map<int, int> > T;

  int main() {
    T v;
    T::const_iterator i=v.begin();
    if( i != v.end() )
      return 1;
  }

Concerning the error message, well, this is a bug^Wfeature of its own. :-(

 x.cc: In function `int main()':
 x.cc:10: no match for `std::_Rb_tree_iterator<std::pair<const int,
   std::map<int, int, std::less<int>, std::allocator<std::pair<const int, int>
   > > >, const std::pair<const int, std::map<int, int, std::less<int>,
   std::allocator<std::pair<const int, int> > > >&, const std::pair<const int,
   std::map<int, int, std::less<int>, std::allocator<std::pair<const int, int>
   > > >*>& != std::_Rb_tree_iterator<std::pair<const int, std::map<int, int,
   std::less<int>, std::allocator<std::pair<const int, int> > > >,
   std::pair<const int, std::map<int, int, std::less<int>,
   std::allocator<std::pair<const int, int> > > >&, std::pair<const int,
   std::map<int, int, std::less<int>, std::allocator<std::pair<const int, int>
   > > >*>' operator

Gerald
-- 
Gerald "Jerry" pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/



More information about the Gcc-bugs mailing list