Can someone explain why opCast is so limited?

Funog funog at ifrance.com
Thu Sep 6 10:12:21 PDT 2007


Steven Schveighoffer Wrote:

> Question #1: I know that because you cannot overload functions based on the 
> return type, they are limited.  But casting is more of a function with type 
> as the parameter.  i.e.:
> 
> cast(Type)value;
> 
> I look at Type and value as the parameters to the cast.  Why doesn't opCast 
> behave like:
> 
> int opCast(int)
> {
>   return myIntRepresentation;
> }
> 
> float opCast(float)
> {
>   return myFloatRepresentation;
> }
> 


Or maybe void opCast(out int) ?





More information about the Digitalmars-d-learn mailing list