How to break const

Timon Gehr timon.gehr at gmx.ch
Tue Jun 19 10:52:18 PDT 2012


On 06/19/2012 07:40 PM, Christophe Travert wrote:
> Christophe Travert, dans le message (digitalmars.D:170182), a écrit :
>> Timon Gehr , dans le message (digitalmars.D:170178), a écrit :
>>> That is completely unrelated.
>>> It is impossible to justify transitivity of const for delegate context
>>> pointers using this argument. It is far too general and the
>>> justification for the general concept comes from a specific example
>>> that is different from the one at hand.
>>>
>>> The question is, what the meaning of 'const' references should be:
>>>
>>> 1. data cannot be changed transitively through the reference
>>>
>>> 2. the reference can reference both 'const' and 'immutable' data and
>>>      'immutable' data can transitively not be changed through the
>>>      reference.
>>>
>>>
>>> 1. requires transitive const for delegate context pointers, 2. does not.
>>
>> A const reference can contain
>>
>> I don't understand the difference.
>
> Apologies, I forgot to complete my post:
>
> A const reference can contain both mutable and immutable data, as long
> as it does not allow to mutate it.

Exactly,

absolutely no mutation ==> can refer to mutable or immutable data

but

can refer to mutable or immutable data =/=> absolutely no mutation

The question is whether 'const' is there just to tie together mutable
and immutable, or if it is a distinct entity.


More information about the Digitalmars-d mailing list