On 4/8/2013 5:39 AM, Manu wrote:In C++, it is legal to cast away const and mutate it. That is undefined behavior in D.
But D makes no further guarantee. I don't see how const in D is any different
than const in C++ in that sense? That's basically the concept of const, it's not
a useful concept for optimisation, only immutable is.
A D compiler can assume, for example, that a const reference passed to a pure function will not mutate that reference, nor anything transitively referred to by that reference. No such assumption can be made like that in C++.