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

Mehrdad wfunction at hotmail.com
Thu Aug 16 18:17:18 PDT 2012


On Friday, 17 August 2012 at 00:44:20 UTC, Chris Cain wrote:
> On Friday, 17 August 2012 at 00:32:03 UTC, Mehrdad wrote:
>> On Friday, 17 August 2012 at 00:10:52 UTC, Jonathan M Davis 
>> wrote:
>>> In contrast, in D,
>>>
>>> const ref Array!(T*) getStuff() const;
>>>
>>> you would _know_ that not only is the container not altered,
>>> but you know that the elements aren't altered either -
>>> or anything which the elements point to.
>>
>>
>> I'm not so sure about that.
>> ...snip...
>
> Your example is not equivalent to what he was saying.


How?


Jon said "you know that the elements aren't altered either - or 
anything which the elements point to".


I just showed that the const-ness of getStuff() tells you 
_nothing_ about that fact.

Did I miss something?


More information about the Digitalmars-d mailing list