Friend class within templates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We are busy recompiling code under g++ 3.3.3 (Netbsd 2.0) and have come up
with a couple of problems. The previous compiler was g++ 2.95.3.

One in particular concerns the use of friend classes from within templates
viz the example below.

template<class T> OwnerClass
{
 public:
   ...

 protected:
  friend class T;
  void tellUsSomething() {} // called from T
};

The 3.3.3 compiler gives "error: using template type parameter 'T' after
'class'" which it didn't give under 2.95.3. I have had a look through
Stroustrup's "The C++ Programming Language" and couldn't find a direct
reference to this case, but presume it contravenes the C++ standard in some
way.

I was wondering if this is the case, and if so whether somebody has a clever
way to work around this easily. I have attached a short test program as an
illustration.

Regards
 Stuart

Attachment: testprog.tgz
Description: Binary data


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux