Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Template bug?

4 views
Skip to first unread message

Ben Abraham

unread,
Dec 7, 2009, 12:07:08 PM12/7/09
to bug...@ftp.gnu.org

Ben Abraham
629 East Fifth Street Apt. 20
New York NY 10009


Hi,

There may be bug with respect to templates in g++. The below
program does not compile. It may be some silly mistake on my part. I've
included the diagnostic and version information respectively.


Sincerely,
Ben

#include <vector>

using namespace std;

template <class T>
class TTable1 {
T fType;
public:
void debug() {
vector<T>::iterator it; //this is the line in question (10)
}
};


int main() {

}


$ g++ testTemplate.cpp
testTemplate.cpp: In member function `void TTable1<T>::debug()':
testTemplate.cpp:10: error: expected `;' before "it"


$ g++ --version
g++ (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


It's cygwin version above running on Windows XP Professional.
Version 5.1 (Build 2600.xpsp.050928-11517 : Service Pack 2 (Windows
version)


flew...@gmail.com

unread,
Jan 21, 2010, 5:22:30 PM1/21/10
to

Ben

You need to prefix your 'vector<T>::iterator it' declaration with
'typename ' to inform gcc that this is your intention:

typename vector<T>::iterator it;

That should solve your problem.

Rgds


Paul

0 new messages