This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: STL iterators in gcc 3.2
- From: Alberto Garcia Raboso <Alberto dot Garcia dot Raboso at cern dot ch>
- To: "Moore, Mathew L" <MooreML at BATTELLE dot ORG>
- Cc: "'Alberto Garcia Raboso'" <Alberto dot Garcia dot Raboso at cern dot ch>, gcc-help at gcc dot gnu dot org
- Date: Fri, 25 Oct 2002 17:57:54 +0200 (CEST)
- Subject: RE: STL iterators in gcc 3.2
>
> From what I've noticed, the old 2.95 implemented std::vector iterators as
> just plain pointers (|std::vector<double>| used |double*|'s for iteration).
> It looks like now the library is using class abstractions for its iterators.
> This has many benefits, but it also means that some code, e.g.,
>
> void foo(double*);
> std::vector<double> myvect;
> foo(myvect.begin());
>
> will no longer work, since |myvect.begin()| does not necessarily produce a
> double*.
>
> I have found in order to make your code independent of the iterator object,
> you have to either use templates,
>
> template <typename OutputIterator>
> void foo(OutputIterator);
>
> or you must specifically use the iterator type defined by your container,
>
> void foo(std::vector<double>::iterator);
>
> I don't know if there is an easier conversion than either of these, but I
> would be interested in hearing any other ideas.
Of course, this explains vey well he problem. But I cannot use new
definitions of the methods using template arguments instead of pointers,
as they come from a library... So I think I'll have to use a previous
version of gcc, at least until I have time to change my code to adhere to
the standards ;-)
Anyway, thank you very much.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Alberto Garcia Raboso
CERN / EP
CH-1211 Geneva 23, Switzerland
Office 40-2B-19 (+41 22 76 71626)
E-Mail: Alberto.Garcia.Raboso@cern.ch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Well, farewell, my hobbits! You should come safe to your own
homes now, and I shall not be kept awake for fear of your
peril. We will send word when we may, and some of us may yet
meet at times; but I fear that we shall not all be gathered
together ever again.
The return of the King. J.R.R. Tolkien
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~