By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,420 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,420 IT Pros & Developers. It's quick & easy.

Templates and user defined conversion operator

P: n/a
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

Jul 23 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.