What guarantees does D 'const' provide, compared to C++?

Mehrdad wfunction at hotmail.com
Thu Aug 16 19:12:10 PDT 2012


On Friday, 17 August 2012 at 02:02:51 UTC, Jonathan M Davis wrote:
> Because there are plenty of functions which take mutable 
> objects but don't actually alter them - particularly when 
> interacting with C code.



Ah, so that explains that, thanks.

So to clarify, modifying a mutable object through casting away a 
const reference is undefined in D, but valid in C++.

Now the only question is what guarantees that actually gives you 
that the compiler can use for optimization (aliasing issue 
above^).


More information about the Digitalmars-d mailing list