c++ - Forward declaration of template class nested inside template class -


you can forward declare template inner class inside normal class, , use defined type other forward declared type.

class outer {     template <int n> class inner;     typedef inner<0> inner0;     inner0* f(); };  template<int n> class outer::inner {}; 

now if outer template class, there way keep declaration of inner outside declaration of outer ? :

template<typename t> class outer {     template <int n> class inner;     typedef inner<0> inner0;     inner0* f(); };  template<typename t, int n> //this won't work class outer<t>::inner {}; 

is there correct syntax declare outer right template parameters ?

try following

template<typename t> template <int n> class outer<t>::inner {}; 

according c++ standard (14.5.2 member templates)

1 template can declared within class or class template; such template called member template. member template can defined within or outside class definition or class template definition. a member template of class template defined outside of class template definition shall specified template-parameters of class template followed template-parameters of member template.


Comments