Hi all,
I would really love to do the following:
template<class T>
class A
{
public:
A(T *pT)
{
aT = pT;
}
template<class T2>
operator A<T2>() // <- compile error here
{
return A<T2>(aT);
}
private:
A *aT;
};
but CW6 returns "declaration syntax error". It seems that the compiler does
not recognise A<T2> as a valid type and hence expects a return type where
the operator keyword is. The following compiles without error:
template<class T>
class A
{
public:
A(T *pT)
{
aT = pT;
}
template<class T2>
void foo()
{
}
template<class T3>
void operator++()
{
}
private:
A *aT;
};
The reason I am doing this is for a "smart pointers" implementation - the
alternative to this method being an explicit converter:
template<class T>
class A
{
//...
template<class T2>
A<T2> convertTo()
{
return A<T2>(aT);
}
}
but implicit conversion would be much nicer... so, is this a compiler bug
and, if so, any other workaround suggestions?
______________________________________________
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html