My C++ skills are a little rusty, specifically concerning templates, and for the life of me I can’t figure out what the problem is with the following code snippet (abstracted from a larger program, obviously):
template<class T> struct Bar
{
struct Baz { };
};
template<class T> void Foo()
{
Bar<int>::Baz baz_int;
Bar<T>::Baz baz_t;
};
When I try to compile the above code (under g++ 3.4.6 on a Linux box) it chokes on the declaration of baz_t. Specifically, I get
error: expected `;' before "baz_t"
Which suggests that the code isn’t parsing properly, but then why doesn’t the compiler have any problems with the declaration of “baz_int”?
I’m trying to create a template class that uses the STL classes as members, but if I can’t figure this problem out that will be rather difficult: replace “Bar” with “std::list” and “Baz” with “iterator” and you’ll see why I want to know what the heck I’m doing wrong.
Help, please! Does anybody know what the problem is?