Overloading cast

Tim M a at b.com
Tue Nov 11 03:49:31 PST 2008


http://www.digitalmars.com/d/2.0/operator-overloading.html#Unary

"The member function e.opCast() is called, and the return value of  
opCast() is implicitly converted to type. Since functions cannot be  
overloaded based on return value, there can be only one opCast per struct  
or class."

I've come across a situation where opcast to different types would be very  
useful. Why can't this be overloaded to cast to different types as a  
special situation for overloading on return types. Very useful IMHO.



More information about the Digitalmars-d mailing list