How to declare a templated struct/class as a friend?

template<typename> friend class foo

this will however make all templates friends to each other. But I think this is what you want?