O
Ole Nielsby
Porting a project from VC8 to GCC, I stumbled on this:
I have certain templates that use STL collections with a
value type that is a pointer to a template parameter type.
When I declare iterators for these parametrized collections,
GCC chokes.
template class MapWrapper<T> {
std::map<MyKey, T*> myMap; // OK with both compilers
myMethod(){
std::map<MyKey, T*>::iterator i; // GCC chokes
}
}
Did I get the syntax wrong, or is GCC buggy here?
I circumvented it by using B* as the map value type,
where B is a common base class for the T classes used,
combined with unchecked (C-style) casts - but this isn't
supposed to be necessary when working with templates.
I have certain templates that use STL collections with a
value type that is a pointer to a template parameter type.
When I declare iterators for these parametrized collections,
GCC chokes.
template class MapWrapper<T> {
std::map<MyKey, T*> myMap; // OK with both compilers
myMethod(){
std::map<MyKey, T*>::iterator i; // GCC chokes
}
}
Did I get the syntax wrong, or is GCC buggy here?
I circumvented it by using B* as the map value type,
where B is a common base class for the T classes used,
combined with unchecked (C-style) casts - but this isn't
supposed to be necessary when working with templates.