automatic conversion to invariant (string?)

Janice Caron caron800 at googlemail.com
Thu Mar 20 04:05:44 PDT 2008


On 20/03/2008, Yossarian <xtauer01 at stud.fit.vutbr.cz> wrote:
>  wouldn't
>  this 'downcast' be logical?'

No. Example:

    char[] s = cast(char[]) "hello";
    string t = s;
    s[0] = 'j';

There's a good reason why that won't compile!

Both mutable and invariant will downcast to const, so from const to
either mutable or invariant is an upcast. That makes going from
mutable to invariant a "sideways cast"



More information about the Digitalmars-d mailing list