How can you establish a friendly connection between a regular class and a class template?

Suppose we have a template class MyArray template <typename Type> class MyArray; and the usual class ArrayEditor class ArrayEditor;

How can I establish a friendly relationship between them (friend class) :

  1. Between the ArrayEditor class and all instances of the MyArray template?

  2. Between the ArrayEditor class and a specific instance (for example int or string)?

    1 answer 1

    Between the non- NotemplateClass class and the generic TemplateClass<T> class:

     template <typename T> class TemplateClass{}; class NotemplateClass { template<typename T> friend class TemplateClass; }; 

    Between the non- NotemplateClass class and the explicit specialization of the TemplateClass<int> template class:

     template <typename T> class TemplateClass{}; template <> class TemplateClass<int>{}; class NotemplateClass { friend class TemplateClass<int>; }; 
    • Hmm, so simple! Thanks - Nexeon
    • @Nexeon Yes, that's all it is, not at all :) - StateItPrimitive