How to break const

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Jun 18 07:37:25 PDT 2012


On 6/18/12 1:35 AM, Matthias Walter wrote:
> On 06/18/2012 08:19 AM, Mehrdad wrote:
>> On Monday, 18 June 2012 at 06:14:22 UTC, Matthias Walter wrote:
>>> Its not, that a const method cannot modify an object, it just
>>> ensures that the const method cannot modify the object *by using
>>> the this-pointer*.
>>
>>
>>
>> I see...
>>
>>
>> So that means you /can't/ tell something just by looking at a part
>> of the code, right?
>>
>> (Just mentioning this since this idea seemed to be emphasized a lot
>> by D.)
>
> Yes, you are right with that.

Actually things are a fair amount subtler. On the face of it, immutable 
does fulfill the OP's expectation. But even for const code, there's 
still a lot of guarantees that can be inferred depending on the types 
involved.

Andrei



More information about the Digitalmars-d mailing list