VC++ 7.1 friend template problem

  • Thread starter Thread starter Jaroslav Gresula
  • Start date Start date
J

Jaroslav Gresula

Consider the following code:

template<class T>
struct Singleton
{
static T& Instance()
{
static T instance;
return instance;

}
};

template<class T>
struct A : public Singleton<A<T> >
{
// causes error C2245
friend A& Singleton<A<T> >::Instance();
};

A<int>& i = A<int>::Instance();

Comeau online is OK with it, VC++ is not.
It is a bug or am I missing something?

Cheers,
Jarda
 
Jaroslav said:
Consider the following code:

template<class T>
struct Singleton
{
static T& Instance()
{
static T instance;
return instance;

}
};

template<class T>
struct A : public Singleton<A<T> >
{
// causes error C2245
friend A& Singleton<A<T> >::Instance();
};

A<int>& i = A<int>::Instance();

Comeau online is OK with it, VC++ is not.
It is a bug or am I missing something?

Looks like a bug to me.

-cd
 
Back
Top