473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

STL initialize iterator problem with compiler change


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

Jun 5 '06 #1
4 3982
br*******@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)

For the change in the increment, see

http://www.parashift.com/c++-faq-lit...html#faq-13.15

Cheers! --M

Jun 5 '06 #2
mlimber wrote:
br*******@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

For the change in the increment, see

http://www.parashift.com/c++-faq-lit...html#faq-13.15

Cheers! --M


--
Posted via a free Usenet account from http://www.teranews.com

Jun 13 '06 #3

Pedro Sousa wrote:
mlimber wrote:
br*******@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-lit...t.html#faq-5.9

Cheers! --M

Jun 13 '06 #4
On Tue, 13 Jun 2006 19:25:21 +0000, Pedro Sousa <pa*****@inbox.com>
wrote:
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...disambiguation
Jun 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Michael Klatt | last post by:
I am trying to write an iterator for a std::set that allows the iterator target to be modified. Here is some relvant code: template <class Set> // Set is an instance of std::set<> class...
5
by: Johann Gerell | last post by:
I have this iterator: class CFileIterator : public std::iterator<std::input_iterator_tag, const std::wstring> { public: CFileIterator(const std::wstring& wildcardPath); .... };
3
by: Ken Cecka | last post by:
This is a contrived example to demonstrate a syntax problem I'm struggling with: #include <vector> template <typename T> class Class { };
14
by: shawnk | last post by:
I searched the net to see if other developers have been looking for a writable iterator in C#. I found much discussion and thus this post. Currently (C# 2) you can not pass ref and out arguments...
18
by: silversurfer | last post by:
Ok, this should be fairly easy for most of you (at least I hope so), but not for me: Let us say we have got the following elements: std::vector<Entry> models; //Entry is a struct...
2
by: heng | last post by:
If the data member of a class is an array, how to initialize? I tried the following, but it is wrong. class A { public: int a; A():a({0,0,0}){} };
1
by: atomik.fungus | last post by:
Hi, I'm re-writting my matrix class to practice my programming and the computer doesn't let me compile the next code: ( this example come from the constructor of the class) //the matrix is made...
3
by: vasili | last post by:
hello All, I have a simple issue. I defined a custom container, that encloses a std::list, which in turn holds objects that are a simple abstraction of a six position array. Now, i would like...
9
by: void main | last post by:
I'm rather new to complex numbers in C and was wondering, how do I initialize a complex variable properly if the imaginary part is 0. I tried -------- #include <complex.h> float complex c...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.