How to break const

Mehrdad wfunction at hotmail.com
Sun Jun 17 22:36:26 PDT 2012


Is it just me, or did I subvert the type system here?


import std.stdio;

struct Const
{
	this(void delegate() increment)
	{ this.increment = increment; }
	int a;
	void delegate() increment;
	void oops() const { this.increment(); }
}

void main()
{
	Const c;
	c = Const({ c.a++; });
	writeln(c.a);
	c.oops();
	writeln(c.a);
}


More information about the Digitalmars-d mailing list