* g++ 3.4.3 template error
@ 2005-09-02 17:58 David Brumley
2005-09-02 18:09 ` Eljay Love-Jensen
0 siblings, 1 reply; 2+ messages in thread
From: David Brumley @ 2005-09-02 17:58 UTC (permalink / raw)
To: gcc-help
Hello,
I'm having a problem with template functions in some legacy code i'm
trying to get working. I can reproduce the error in the following
small example:
include <map>
#include <iterator>
using namespace std;
class foo {
public:
foo(){};
template<class T> void setval(){
map<T,int> mymap;
map<T,int>::iterator it;
}
};
The decl of mymap succeeds, or at least there is no compile-time
error. The iterator it decl fails with the error
error: expected `;' before "it"
I nor anyone else around me have been able to figure out a way to get
the iterator decl of a template function to work. Is this a bug, or
something I am not doing right? From what I understand this code
compiled fine under old versions of g++.
Or is there a workaround? Essentially I need to make it so the
iterator over a map is a template type.
Thanks,
david
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: g++ 3.4.3 template error
2005-09-02 17:58 g++ 3.4.3 template error David Brumley
@ 2005-09-02 18:09 ` Eljay Love-Jensen
0 siblings, 0 replies; 2+ messages in thread
From: Eljay Love-Jensen @ 2005-09-02 18:09 UTC (permalink / raw)
To: David Brumley, gcc-help
Hi David,
Try this fixed code...
#include <map>
#include <iterator>
using namespace std;
class foo {
public:
foo() { }
template<class T>
void setval()
{
map<T,int> mymap;
typename map<T,int>::iterator it;
}
};
HTH,
--Eljay
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-09-02 18:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-02 17:58 g++ 3.4.3 template error David Brumley
2005-09-02 18:09 ` Eljay Love-Jensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).