C++ mutable in D

Gollan gollan at mail.com
Sat Jul 31 12:27:28 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:
> 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.
>

I'm really surprised you think it doesn't make much sense. What 
about:

- Locking a mutex to avoid data races when returning a class 
member from a const getter function
- Lazy resource allocation (caching) on first call of a const 
member function


More information about the Digitalmars-d mailing list