🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #122

Accessing nested classes from friend functions

#122
From: Aaron Emigh
Date: Mon, 17 Aug 1992 23:01
36 lines
1723 bytes
I was trying to write a friend function of a template class containing
another class taking a pointer to the internal class as an argument, and
couldn't find any way to get my compiler (Borland C++ 3.0) to accept it.
I couldn't find anything clear in my documentation, so I'm wondering if
there is a defined syntax for doing this.

In case I'm not being clear, here's an example of what I mean (semantic
content has been reduced to null in the interests of brevity).

// A do-nothing template class containing only another class and a
// friend function, for demonstration purposes.

template <class type_instance_t>
class class_t {
  class internal_t {
    type_instance_t foo;
  };
  friend void frob_class (internal_t *);
};


// Here's the question: how do I declare a friend function that takes a
// class nested inside a template class as an argument?

template <class type_instance_t>
void frob_class (class_t<type_instance_t>::internal_t *arg)
{
}

For my application, declaring internal_t separately and making
class_t its friend works fine, but is less correct in terms of the
operations I am supporting.  Is there a defined way of implementing this
with the class definitions nested?

Aaron Emigh
aaron@iit.com
Technical Details
Message-ID: <1992Aug17.230118.1758@iitinc.uucp>
Path: arc1-ca.pugleaf.net!sparky!uunet!sun-barr!news2me.ebay.sun.com!exodus.Eng.Sun.COM!sun!imagen!iitinc!aaron

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!sun-barr!news2me.ebay.sun.com!exodus.Eng.Sun.COM!sun!imagen!iitinc!aaron
From: aaron@iit.com (Aaron Emigh)
Newsgroups: comp.std.c++
Subject: Accessing nested classes from friend functions
Keywords: template class friend
Message-ID: <1992Aug17.230118.1758@iitinc.uucp>
Date: 17 Aug 92 23:01:18 GMT
Sender: aaron@iitinc.uucp (Aaron Emigh)
Reply-To: aaron@iit.com (Aaron Emigh)
Organization: Integrated Information Technology
Lines: 36