Casting between char[]/wchar[]/dchar[]

Hasan Aljudy hasan.aljudy at gmail.com
Fri Aug 4 22:22:04 PDT 2006


What are the rules for implicit/explicit casting between char[] and 
wchar[] and dchar[] ?

When one casts (explicitly or implicitly) does the compiler 
automatically invoke std.utf.toUTF*()?

Here's an idea that should simplify much of string handling in D:
allow char[] and wchar[] and dchar[] to be castable implicitly to each 
other, provided that the compiler invokes the appropriate std.utf.toUTF* 
method.
I think this is perfectly safe; no data is lost, and string handling can 
become much more flexable.

Instead of writing three version of the same funciton for each of char[] 
wchar[] and dchar[], one can just write a wchar[] version (for example) 
and the compiler will handle the conversion from/to char[] and dchar[].

This is also relevies developers from writing templetized 
functions/class when they deal with strings.

Thoughts?



More information about the Digitalmars-d mailing list