This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Friend class within templates


I didn't read the template standard very closely, but
I figure the gcc folks did.  Anyway, the wrapper below
gets around the issue:


// Forward decl.
template< class T > class Wrapper;

//------------------------------------------//
template<class T> class OwnerTemplate
{
        // friend decl.
	friend class Wrapper< T >;
....
};

template<class T> class Wrapper
{
 public:
    void callOwner( OwnerTemplate<T>* owner )
    { owner->calledFromT(); }
};

....

//-----------------------------------------//
class MyClass
{
....
	void callOwner()
        { Wrapper< MyClass >().callOwner( owner ); }

....
};


Best,

Ben


		
__________________________________
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!
http://advision.webevents.yahoo.com/yahoo/votelifeengine/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]