Вот пример. Я получаю сообщение об ошибке typename T::SubType*
внутри шаблона, но не снаружи.
используя gcc0x я получаю
prog.cpp: In instantiation of 'TemplateBase<A>':
prog.cpp:8:36: instantiated from here
prog.cpp:4:22: error: invalid use of incomplete type 'class A'
prog.cpp:8:7: error: forward declaration of 'class A'
в против меня я получаю несколько случайных сообщений об ошибках. Вот код.
template< typename T >
struct TemplateBase {
void ff() {}
typename T::SubType*f(){ return 0; }
//typename T::SubType*f();
};
class A : public TemplateBase< A > {
public:
//struct SubTypeT {
struct SubType {
int i;
};
//typedef SubTypeT SubType;
private:
SubType m;
};
template<typename T>
typename T::SubType*f(){ return 0; }
int main() {
f<A>();
A a;
a.ff();
}