This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

g++ 3.4.3 template error


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]