I have a template class who needs to be friends of all other classes made from that template.
ie: MyClass<int> needs to be friends with MyClass<float>... however because this is a template that will be used with many user-defined types I can't just list all the possible friends in the class.
I tried following stuff, none of which worked:
1 2 3 4 5 6 7 8 9
template <typename T>
class MyClass
{
friendclass MyClass; // 'MyClass' already friends with itself
friendclass MyClass <>; // wrong number of template arguments
template <typename TT> friendclass MyClass<TT>;
//partial specialization 'MyClass<TT>' declared 'friend'
};
Is this possible?
Thanks in advance
-- [ EDIT ]--
of course it's the one thing I didn't try:
1 2 3 4 5
template <typename T>
class MyClass
{
template <typename TT> friendclass MyClass; // not MyClass<TT>
};