Forward declaration of template class nested inside template class

后端 未结 1 815
遇见更好的自我
遇见更好的自我 2021-01-12 23:58

You can forward declare a template inner class inside a normal class, and use the defined type as any other forward declared type.

class Outer {
    template         


        
相关标签:
1条回答
  • 2021-01-13 00:25

    Try the following

    template<typename T>
    template <int N>
    class Outer<T>::Inner {};
    

    According to the C++ Standard (14.5.2 Member templates)

    1 A template can be declared within a class or class template; such a template is called a member template. A member template can be defined within or outside its class definition or class template definition. A member template of a class template that is defined outside of its class template definition shall be specified with the template-parameters of the class template followed by the template-parameters of the member template.

    0 讨论(0)
提交回复
热议问题