C++ mutable in D
Paulo Pinto
pjmlp at progtools.org
Sun Aug 1 07:58:03 UTC 2021
On Sunday, 1 August 2021 at 06:15:30 UTC, Jack Applegame wrote:
> On Friday, 30 July 2021 at 20:09:19 UTC, Tejas wrote:
>> Also remember that casting away const is undefined behaviour
>> in D (unlike being defined and supported in C++).
>
> No.
> Casting const away IS NOT undefined behavior in both D and C++.
> Modifying a const object IS undefined behavior in both D and
> C++.
> There is not much difference between D and C++ in that way.
Not in C++, when the const object modification is taking place
via member variables declared as mutable accessed from a const
member function.
This is also a thing in Swift and Rust, by the way, they just use
other mechanisms to do the same.
More information about the Digitalmars-d
mailing list