friend class template

  • Thread starter Andrea Cacciarru
  • Start date
A

Andrea Cacciarru

Why
template <class T> class TemplateFriend; //Forward Class "Template"
Declaration

class A {
friend class TemplateFriend; //Any type T!
};

compile well with VC++ 7 but do not compile wit gcc or Comeau? What says
Standard about friend template class declaration?
I have searched some informations about it but without success.

Thanks in advance,
bye Andrea
 
M

Martin Gieseking

Andrea Cacciarru said:
template <class T> class TemplateFriend; //Forward Class "Template"

class A {
friend class TemplateFriend; //Any type T!
};

compile well with VC++ 7 but do not compile wit gcc or Comeau? What says
Standard about friend template class declaration?


As far as I remember you must use a "friend template" with following syntax
to express that all template instances are friends of A:

class A {
template<class T>
friend class TemplateFriend;
};

So g++ and Comeau behave correctly and VC++ does not.

Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,297
Messages
2,571,529
Members
48,243
Latest member
MarkoTuggl

Latest Threads

Top