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

Mehrdad wfunction at hotmail.com
Thu Aug 16 15:14:27 PDT 2012


Something I'm having trouble undertanding/remembering (sorry, 
you've probaby already explained it a billion times)...

I remember being told many times that D's 'const' provides 
stronger guarantees than C++'s 'const'.

I just wanted to clarify, is that true for 'const' itself, or is 
that referring only to when 'const' is used with other D-specific 
features (immutable, etc.)?

If it's the former, is there some example piece of code in each 
language, for comparison, that shows how the compiler can infer 
more from D's const than C++'s?

If so, it might be worth posting something like that on the 
website.


More information about the Digitalmars-d mailing list