The description can be quite mind boggling so I get straight to the example:
#include <iostream>
#include <typeinfo>
using namespace std;
template<typename T> class fr{
static void privatestuff(){
cout<<"private of "<<typeid(T).name()<<endl;
}
public:
template<typename TT> void callsomeone(){
fr<TT>::privatestuff();
}
//template<typename TT> friend void fr<TT>::callsomeone<T>();
//template<> template<typename TT> friend void fr<TT>::callsomeone<T>();
//template<typename TT> template<> friend void fr<TT>::callsomeone<T>();
//no other combinations... how to get it?
};
int main(){
fr<bool> obj;
obj.callsomeone<int>();
}
Basically, I want fr to be able to call fr<int>::privatestuff
. But I'd like also to not expose more than what is needed, so make fr<int>
friend of only fr<bool>::callsomeone<int>
, not fr<bool>::callsomeone<char>
or others.
I can count on c++11 if that's needed.