D2.0: an example of use-case for casting invariant away

BCS ao at pathlink.com
Mon Jun 25 12:45:02 PDT 2007


Reply to Bruno,

> If you're not meant to write any cast, how the hell does one
> accidentally write a cast?

somthing like this maybe?

int[] foo;  // an array of ints

const int[]* pfoo;  // a pointer to an array of ints

auto pdfoo = cast(dchar[]*)pfoo;  // a pointer to the same data but as dchars 


(*pdfoo)[5] = 'h'; //oops





More information about the Digitalmars-d mailing list