niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » C++
STL initialize iterator problem with compiler change
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
Author Message
Roland Pibinger
*nix forums Guru Wannabe


Joined: 31 Mar 2005
Posts: 262

PostPosted: Tue Jun 13, 2006 8:54 pm    Post subject: Re: STL initialize iterator problem with compiler change Reply with quote

On Tue, 13 Jun 2006 19:25:21 +0000, Pedro Sousa <pasousa@inbox.com>
wrote:
Quote:
mlimber wrote:
g++4 is the more conformant compiler on this point. Your for-loop
should read:

for ( typename vector<T>::iterator i = v.begin(); i != v.end(); ++i)

Can you say where I can read g++4 information about this topic?
I would like to learn it's behavior about the iterators.

http://womble.decadentplace.org.uk/c++/template-faq.html#disambiguation
Back to top
Pedro Sousa
*nix forums beginner


Joined: 08 Jun 2006
Posts: 5

PostPosted: Tue Jun 13, 2006 6:32 pm    Post subject: Re: STL initialize iterator problem with compiler change Reply with quote

mlimber wrote:
Quote:
brianhray@gmail.com wrote:
This works find in Dev Studio and Codewarrior but does not compile
GCC4:

template <class T
void SerializeVector(RArchive &ar, vector<T>& v)
{
for (vector<T>::iterator i = v.begin(); i != v.end(); i++)
SerializeVar(ar, *i);
}


I get "error: expected `;' before 'i'". Even if I just have
"vector<T>::iterator i ". Why would changing compilers cause this
problem? Am I doing something wrong? How do I fix?

--bhr

g++4 is the more conformant compiler on this point. Your for-loop
should read:

for ( typename vector<T>::iterator i = v.begin(); i != v.end(); ++i)

Can you say where I can read g++4 information about this topic?

I would like to learn it's behavior about the iterators.

Thanks in advance
Pedro Sousa

Quote:

For the change in the increment, see

http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.15

Cheers! --M


--
Posted via a free Usenet account from http://www.teranews.com
Back to top
mlimber
*nix forums Guru


Joined: 06 Sep 2005
Posts: 1249

PostPosted: Tue Jun 13, 2006 6:31 pm    Post subject: Re: STL initialize iterator problem with compiler change Reply with quote

Pedro Sousa wrote:
Quote:
mlimber wrote:
brianhray@gmail.com wrote:
This works find in Dev Studio and Codewarrior but does not compile
GCC4:

template <class T
void SerializeVector(RArchive &ar, vector<T>& v)
{
for (vector<T>::iterator i = v.begin(); i != v.end(); i++)
SerializeVar(ar, *i);
}


I get "error: expected `;' before 'i'". Even if I just have
"vector<T>::iterator i ". Why would changing compilers cause this
problem? Am I doing something wrong? How do I fix?

--bhr

g++4 is the more conformant compiler on this point. Your for-loop
should read:

for ( typename vector<T>::iterator i = v.begin(); i != v.end(); ++i)

Can you say where I can read g++4 information about this topic?

I would like to learn it's behavior about the iterators.

You should ask in a g++ newsgroup, two of which are listed in this FAQ:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M
Back to top
mlimber
*nix forums Guru


Joined: 06 Sep 2005
Posts: 1249

PostPosted: Mon Jun 05, 2006 6:37 pm    Post subject: Re: STL initialize iterator problem with compiler change Reply with quote

brianhray@gmail.com wrote:
Quote:
This works find in Dev Studio and Codewarrior but does not compile
GCC4:

template <class T
void SerializeVector(RArchive &ar, vector<T>& v)
{
for (vector<T>::iterator i = v.begin(); i != v.end(); i++)
SerializeVar(ar, *i);
}


I get "error: expected `;' before 'i'". Even if I just have
"vector<T>::iterator i ". Why would changing compilers cause this
problem? Am I doing something wrong? How do I fix?

--bhr

g++4 is the more conformant compiler on this point. Your for-loop
should read:

for ( typename vector<T>::iterator i = v.begin(); i != v.end(); ++i)

For the change in the increment, see

http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.15

Cheers! --M
Back to top
brianhray@gmail.com
*nix forums beginner


Joined: 14 Jun 2005
Posts: 4

PostPosted: Mon Jun 05, 2006 6:32 pm    Post subject: STL initialize iterator problem with compiler change Reply with quote

This works find in Dev Studio and Codewarrior but does not compile
GCC4:

template <class T>
void SerializeVector(RArchive &ar, vector<T>& v)
{
for (vector<T>::iterator i = v.begin(); i != v.end(); i++)
SerializeVar(ar, *i);
}


I get "error: expected `;' before 'i'". Even if I just have
"vector<T>::iterator i ". Why would changing compilers cause this
problem? Am I doing something wrong? How do I fix?

--bhr
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
The time now is Fri Jan 09, 2009 5:10 am | All times are GMT
navigation Forum index » Programming » C++
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Unknown in header problem -SOLVED- Light Speed Postfix 0 Thu Jul 03, 2008 10:40 am
No new posts problem with sending mail nuxia Postfix 0 Mon Apr 21, 2008 3:58 am
No new posts Postfix 2.3.8 Virtual problem Blotto Postfix 0 Fri Apr 04, 2008 6:11 am
No new posts Postfix sending problem for local domain remote email monkey_magix Postfix 0 Mon Sep 10, 2007 10:17 am
No new posts bounce problem murkis Postfix 0 Sun Oct 08, 2006 3:45 pm

Loans | Bankruptcy | Buy WoW Gold | Advertising | Loans and Credit Cards
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 1.3106s ][ Queries: 20 (1.2131s) ][ GZIP on - Debug on ]