Connecting Tech Pros Worldwide Help | Site Map

template friend function

  #1  
Old July 22nd, 2005, 06:10 AM
Marc Schellens
Guest
 
Posts: n/a
I have:

template<class Sp>
class Data_: public Sp
{
public:
typedef typename Sp::Ty Ty;
typedef Sp Traits;

private:
typedef typename Sp::DataT DataT;
DataT dd; // the data

public:
//structors

~Data_() {};

// default
Data_(): Sp(), dd() {}

....

// line 169
// convert *this to other 'destTy'
BaseGDL* Convert2( DType destTy,
BaseGDL::Convert2Mode=BaseGDL::CONVERT);

// line 174
// make all other Convert2 functions friends
template<class Sp2>
friend BaseGDL* Data_<Sp2>::Convert2( DType destTy,
BaseGDL::Convert2Mode);

....
};

which compiles fine with gcc 3.2
But with gcc 3.3 I got:

datatypes.hpp:174: error: prototype for `template<class Sp2> BaseGDL*
Data_::Convert2(DType, BaseGDL::Convert2Mode)' does not match any in
class `Data_<<anonymous template type parameter> >'
datatypes.hpp:169: error: candidate is: BaseGDL* Data_<<anonymous
template type parameter> >::Convert2(DType, BaseGDL::Convert2Mode)

Question: is this not standard conform? If not, any suggestions how to
do it (having one template member function wich is friend to all
instantiations of the template)?
Or is it a glitch in the compiler?

thanks,
marc

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Template friend function injection H9XLrv5oXVNvHiUI@spambox.us answers 21 July 11th, 2008 11:25 PM
Error while testing the "non-template friend function of a templateclass" Pierre Barbier de Reuille answers 3 August 4th, 2006 11:35 AM
Problem with defining template friend function of a template class. PengYu.UT@gmail.com answers 2 November 9th, 2005 08:45 PM
Template Friend Function Dmitry D answers 1 July 19th, 2005 08:53 PM
Template Friend Function, GCC and C++ FAQ Lite Christophe Barbe answers 2 July 19th, 2005 08:28 PM