Friend class within templates

b u bnulbig@yahoo.com
Mon Jul 19 18:58:00 GMT 2004


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/



More information about the Gcc-help mailing list