g++ 3.4.3 template error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux