G
Gianni Mariani
Does anyone know the wisdom behind this ?
I want to make a template whose parameter needs to be a friend.
What's the right(TM) way to do this ?
template <typename T, typename TF>
class Boo
{
friend class TF; // error: using template type
// parameter `TF' after `class'
friend TF; // error: template parameters cannot be friends
template <typename TF2>
class Obfuscator
{
public:
typedef TF2 ObfusType;
};
// the following seems to work for GCC but not MSVC
friend class Obfuscator<TF>::ObfusType;
public:
T value;
};
class Tester
{
public:
Tester()
{
Boo< int, Tester > x;
x.value = 1;
}
};
I want to make a template whose parameter needs to be a friend.
What's the right(TM) way to do this ?
template <typename T, typename TF>
class Boo
{
friend class TF; // error: using template type
// parameter `TF' after `class'
friend TF; // error: template parameters cannot be friends
template <typename TF2>
class Obfuscator
{
public:
typedef TF2 ObfusType;
};
// the following seems to work for GCC but not MSVC
friend class Obfuscator<TF>::ObfusType;
public:
T value;
};
class Tester
{
public:
Tester()
{
Boo< int, Tester > x;
x.value = 1;
}
};