From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9086 invoked by alias); 25 Oct 2002 15:43:29 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 9022 invoked from network); 25 Oct 2002 15:43:28 -0000 Received: from unknown (HELO bclcl1.im.battelle.org) (131.167.1.2) by sources.redhat.com with SMTP; 25 Oct 2002 15:43:28 -0000 Received: from ns-bco-scn1.im.battelle.org ([131.167.1.122]) by BCLCL1 (PMDF V5.1-10 #U2779) with SMTP id <01KO2X1ESV2Y95S9XZ@BCLCL1> for gcc-help@gcc.gnu.org; Fri, 25 Oct 2002 11:43:34 EDT Received: from 131.167.1.91 by ns-bco-scn1.im.battelle.org (InterScan E-Mail VirusWall NT); Fri, 25 Oct 2002 11:43:22 -0400 Received: by ws-bco-mse1.milky-way.battelle.org with Internet Mail Service (5.5.2655.55) id ; Fri, 25 Oct 2002 11:43:22 -0400 Date: Fri, 25 Oct 2002 08:43:00 -0000 From: "Moore, Mathew L" Subject: RE: STL iterators in gcc 3.2 To: 'Alberto Garcia Raboso' , gcc-help@gcc.gnu.org Message-id: <2F05A390F72A0A409390E016D23E45E8042DBECB@ns-bco-mse4.im.battelle.org> MIME-version: 1.0 Content-type: text/plain; charset="iso-8859-1" X-SW-Source: 2002-10/txt/msg00320.txt.bz2 > > 1.- Whereas I didn't need it before, now I have to use the "using > namespace std" directive if I want to use cout, cin,... and all this > stuff. Why the change? > This version of gcc (and g++) is more standards compliant, hence the new necessity of std:: when using the iostreams and other standard library features. > 2.- This is more serious. In my programs I use a lot of STL > vectors, and > so, iterators too. When I had a method with a pointer > argument, I passed a > random iterator to it. It worked fine with previous versions > of gcc, but > not with 3.2. Is there any way to get it work or do I have to > come back to > an older version? > >From what I've noticed, the old 2.95 implemented std::vector iterators as just plain pointers (|std::vector| 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 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 void foo(OutputIterator); or you must specifically use the iterator type defined by your container, void foo(std::vector::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. --Matt