Hi Trent,
Unfortunately, what you are trying to do is not supported in the current set
of compilers used in CW for Palm R6. It is a 'conversion function template'
and this feature isn't yet supported; this feature will be part of our next
major compiler update (Pro 6). For now, you might probably want to stick
with the explicit conversion function template.
Rgds,
Jun-Kiat Lam
Metrowerks Technical Support
----- Original Message -----
From: "Trent Hill" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Thursday, April 27, 2000 2:56 AM
Subject: [CW] member templates and implicit conversion
> 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
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/