This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: 1.1b: g++ won't make sets of some iterators
- To: "J.H.M. Dassen" <jdassen at wi dot leidenuniv dot nl>
- Subject: Re: 1.1b: g++ won't make sets of some iterators
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 02 Oct 1998 01:03:01 -300
- Cc: egcs-bugs at cygnus dot com, 27266 at bugs dot debian dot org
- References: <19981001222058.C19471@zensunni>
J H M Dassen <jdassen@wi.leidenuniv.nl> writes:
> G++ will not allow me to make sets of some kinds of iterators. The following
> code illustrates this problem:
> typedef list<int> SceneList;
> typedef SceneList::const_iterator ModelIndex;
> typedef set<ModelIndex> ModelSet;
> /usr/include/g++/stl_function.h:100: no match for `const __list_iterator<int,const int &,const int *> & < const __list_iterator<int,const int &,const int *> &'
It's complaining that it cannot compare two instances of ModelIndex,
which is correct, since no operator< is available for bidirectional
iterators like the ones of list and set, because they cannot be
implemented efficiently. If you really need this set, you may provide
a comparison operator as an additional argument to template class set.
> Making "SceneList" a set also causes an error, but making it a
> vector causes everything to compile okay.
Of course, vector iterators are random-access iterators, that can be
compared.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil