This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Can not declare std::map::iterator in template (error: expected `;' before "my_A_iterator")
- From: Erik <sigra at home dot se>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 16 Jan 2008 16:36:06 +0100
- Subject: Can not declare std::map::iterator in template (error: expected `;' before "my_A_iterator")
I have the strange problem that I can not declare a std::map::iterator
inside a template:
#include <map>
template<typename S> struct A {};
template<typename T> struct B {
typedef A<T> G;
void f(G const & a) {
std::map<G const *, int> my_As;
std::map<G const *, int>::iterator my_A_iterator = my_As.find(&a);
}
};
The compiler says «error: expected `;' before "my_A_iterator"». If I
change A<T> to for example bool, it compiles. What could possibly be
wrong? I tried both g++-4.2.1 and g++-4.2.2.