Possible syntax for multiple opCast functions

BCS ao at pathlink.com
Fri Jul 20 15:33:20 PDT 2007


Reply to Ender,

> B Shropshire Wrote:
> 
>> How about treat the opCast function as if it were a template:
>> 
>> Class A
>> {
>> int opCast!(int)() { ... }    // the opCast operator for casting to int
>> char opCast!(char)() { ... } // the opCast operator for casting to char
>> B opCast!(B)() { ... }   // the opCast operator for casting to B
>> }
> rather than have multiple cast use functions like toInt, toChar, toB,
> for derived types use symbols ex: use toInt_ptr for int* or toInt_ar
> for int[] or toInt_ar2 for int[2]
> 
> what is needed is implicit conversions
> 

?? I don't follow.





More information about the Digitalmars-d mailing list