Templates and user defined conversion operator

U

uvts_cvs

Hi to everybody, can someone help me?

This compiles in C++:

struct Foo
{
// Function template bar
template <class T>
void bar (T t){}
// Function bar that forwards to bar<T> [with T=int]
void bar (int i){fun<int>(i);}
};

But what if you consider in place of bar the user defined conversion
operator?
How can I express in a correct way the next chunk of code?

This doesn't compile:

struct Foo
{
// Template user defined conversion
template <class T>
operator T (){}
// I would like to forward to operator T [with T=int]
operator int (){operator int<int>();}
};

Is there a way to distinguish between operaror int and operator T [with
T=int]?

Thank you in advance,
Regards Daniele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top