Casting away const and invariant

Janice Caron caron800 at googlemail.com
Sun Sep 9 05:42:24 PDT 2007


Also, if this were the /only/ way to cast away constness, it would
considerably reduce undefined behavior caused by silly mistakes which
could now be caught at compile time. Imagine...

const(int)* p;
auto q = cast(void *) p; /* Error - p is const */
auto q = cast(void *) cast(!const) p; /* OK */



More information about the Digitalmars-d mailing list