Search code examples
c++syntaxclass-template

Correct syntax of making a "class template" friend to a class


I just need:

Correct syntax of making a "class template" friend to a class


Solution

  • Given a class template, for example

    template <typename> class Template;
    

    you can either befriend a particular specialisation of the template:

    friend class Template<int>;
    

    or all specialisations:

    template <typename> friend class Template;