To help LDC/GDC
Walter Bright
newshound2 at digitalmars.com
Mon Apr 8 20:30:31 PDT 2013
On 4/8/2013 5:39 AM, Manu wrote:
> 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.
In C++, it is legal to cast away const and mutate it. That is undefined behavior
in D.
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++.
More information about the Digitalmars-d
mailing list