Alex Rivera | Logout

C++: Is it possible to friend all instances of a template class?

Asked 2011-12-19T23:36:30.257
10

I have a template class called RenderShader, I also have a class called Render. I would like to have all instances of the RenderShader template class to be friends with Render. Also the user is allowed to make their own RenderShader instances so it's not possible to list all of them in the main header file. For Example:

template<class vertdef>
class RenderShader
{
public:
.....
};

class Render
{
    friend class RenderShader;
public:
    ....
};

The syntax "friend RenderShader" is wrong, is there a correct syntax for what I would like to do?

Edit
Report

1 Answer

17
class Render
{
    template<class vertdef>
    friend class RenderShader;
public:
    ....
};
answered 2011-12-19T23:39:44.413

Your Answer