Friend with a certain template class : "template<ANY...> friend class A;"

Viewed 136

Is there a way to declare friend with a template class in a wildcard way?

Example

I always declare friend like this :-

//B.h
template<class T1,class T2>class B{}; 
//C.h
class C{                              
    template<class,class> friend class B;
};

However, if B template argument is changed, I will have to updated C which is usually a far-separated header.

//B.h
template<int T3,class T1,class T2>class B{}; 
//C.h
class C{                              
    template<int,class,class> friend class B;  //<-- manually update here too
};

It causes minor maintainability problem. (For me, once every week.)

Question

Can I do something like this?

class C{                              
    template<ANY...> friend class B; 
};

Is it just impossible?

I faintly feel that this question might be duplicated, because it is probably a common issue.
However, I can't find one.

1 Answers
Related