473,396 Members | 1,997 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,396 software developers and data experts.

template iterators

Hi,

I have a template matrix class that wraps a std::vector. However, the
compiler is complaining about this:

typedef std::vector<T>::iterator iter;
typedef std::vector<T>::const_iterator citer;

iter begin(){ return mMatrix.begin(); }
iter end() { return mMatrix.end(); }

citer begin() const { return mMatrix.begin(); }
citer end() const { return mMatrix.end(); }

Any ideas? It compiles on VC++ 2002, but not on VC++ 2003.
Oct 3 '05 #1
2 1683
springer wrote:
I have a template matrix class that wraps a std::vector. However, the
compiler is complaining about this:

typedef std::vector<T>::iterator iter;
typedef std::vector<T>::const_iterator citer;

iter begin(){ return mMatrix.begin(); }
iter end() { return mMatrix.end(); }

citer begin() const { return mMatrix.begin(); }
citer end() const { return mMatrix.end(); }

Any ideas? It compiles on VC++ 2002, but not on VC++ 2003.


Throw away VC++ 2002. Keep using 2003. Add the 'typename' right
after 'typedef'. Example:

typedef typename std::vector<T>::iterator iter;

V
Oct 3 '05 #2
springer wrote:
Hi,

I have a template matrix class that wraps a std::vector. However, the
compiler is complaining about this:

typedef std::vector<T>::iterator iter;
typedef std::vector<T>::const_iterator citer;

iter begin(){ return mMatrix.begin(); }
iter end() { return mMatrix.end(); }

citer begin() const { return mMatrix.begin(); }
citer end() const { return mMatrix.end(); }

Any ideas? It compiles on VC++ 2002, but not on VC++ 2003.


It's unclear. Post more of the code, and show us the error messages.

Is your matrix 2-D? That is, does mMatrix.begin() actually return
std::vector< vector<T> >::iterator? (Doubtful, but just in case.)

Cheers! --M

Oct 3 '05 #3

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

Similar topics

7
by: Lieven | last post by:
I want to make a function template that is generic over all of the stl-containers. This function can take a vector, a set or stack as input and as second argument the class of the contents of the...
9
by: Jon Wilson | last post by:
I have a class which needs to accumulate data. The way we get this data is by calling a member function which returns float on a number of different objects of different type (they are all the...
15
by: silverburgh.meryl | last post by:
Hi, I am trying to write a transform_until template. It is bascially doing what transform is doing except if UnaryOperation return NULL, it will break out from the loop. Here is the code, but...
2
by: coolpint | last post by:
Can anyone kindly provide an explanation as to why the compiler does not "see" the function template in the contrieved code below? I think the argument deduction fails but can't figure out...
3
by: Pierre Barbier de Reuille | last post by:
Hi, after reading the article " The Standard Librarian : Defining Iterators and Const Iterators" from Matt Austern:...
8
by: r3694117 | last post by:
i am a kookie in C++ ,and don't understand many things like following example. Write a function template palindrome that takes a vector parameter and returns TRue or false according to whether...
45
by: charles.lobo | last post by:
Hi, I have recently begun using templates in C++ and have found it to be quite useful. However, hearing stories of code bloat and assorted problems I decided to write a couple of small programs...
7
by: utab | last post by:
Dear all, I was experimenting with a template taking two iterators for the range of a vector.(Perhaps, it is sth simple and I am missing it because it is a late hour.) I ran into problems in...
3
by: utab | last post by:
Dear all, I have the below template (1) which I would like to implement to accept either a vector or an array. I thought on it some time and came with a solution as in (2) , however the call of...
5
by: maverik | last post by:
Hi all. I'm implementing class AbstractCollection - just a wrap on std::vector - to hide from clients the fact of using std::vector in the base (because in the future I may change vector to a...
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.