Best practices for logical const

Timon Gehr timon.gehr at gmx.ch
Sat Feb 15 11:43:21 PST 2014


On 02/15/2014 08:34 PM, Jesse Phillips wrote:
> But mutating a mutable address is still valid, so as long as _you_
> guarantee the address is not immutable, no it won't format your harddrive.

class C{ bool doit = true; }
void foo(const(C) c)pure{ (cast()C).doit = false; }

void main(){
     auto c = new C;
     writeln(c.doit);
     foo(c);
     if(c.doit) formatHardDrive();
}


More information about the Digitalmars-d mailing list