C++ mutable in D

Tejas notrealemail at gmail.com
Sat Jul 31 05:44:40 UTC 2021


On Friday, 30 July 2021 at 21:53:01 UTC, IGotD- wrote:
> On Friday, 30 July 2021 at 20:09:19 UTC, Tejas wrote:
>>
>> Nope. No logical const, head const, or tail const in D; just 
>> pure transitive const.
>>
>> Also remember that casting away const is undefined behaviour 
>> in D (unlike being defined and supported in C++).
>
> Thank you D for not having "mutable" as in C++. I don't see 
> mutable often in C++ and is one of those corners in C++ that I 
> don't think make much sense.
>
> const is const, easy. In C++ const might not be ROMable. In D 
> immutable is ROMable and transistive const helps this (unless 
> there is some escape hatch I don't know about).

Well, Jonathan Davies disagrees:
http://jmdavisprog.com/articles/why-const-sucks.html


More information about the Digitalmars-d mailing list