Eric wrote in news:2e**************************@posting.google.c om:

Say you have the following:

template <typename _T>

Note that identifiers that begin with an underscore followed by one

of A through Z are reserved for the implementation, for eg your

std library implementation my define _T as a macro, don't use such

identifiers,

struct A {

typedef _T T;

A (T t);

operator T () const;

};

How do you define the T conversion operator?

template <typename Type >

struct A

{

typedef Type T;

A (T t) {}

operator T () const;

};

template < typename Type >

A< Type >::operator typename A< Type >::T () const

{

return T();

}

You could also in this case of writen this,

template < typename Type >

A< Type >::operator Type () const

{

return T(); // or Type();

}

Or (if inline is Ok) inside the class/struct,

template <typename Type >

struct A

{

typedef Type T;

A (T t) {}

operator T () const

{

return T();

}

};

HTH.

Rob.

--

http://www.victim-prime.dsl.pipex.com/