Possible syntax for multiple opCast functions

Ender KaShae astrothayne at gmail.com
Fri Jul 20 14:11:44 PDT 2007


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
> 




More information about the Digitalmars-d mailing list