On Sunday, 26 April 2015 at 04:52:36 UTC, Jonathan M Davis wrote:
It's only undefined if mutation is involved, though I don't know if mutation is involved in this case or not
I was thinking that a class can define an arbitrary toString() that modifies it some of its member variables, which definitely breaks const-correctness.
class CustomToString { int n; override string toString() { n = 1; return "Uh oh"; } } void main() { import std.stdio; immutable c = new CustomToString(); writeln(cast()c); }