C++ to D: mutable

Jonathan M Davis jmdavisProg at gmx.com
Thu Mar 24 00:30:00 PDT 2011


> Greetings,
> 
> I have a C++ class that I would like to rewrite it in D.  The class
> has members that are declared as 'mutable'.  How do I achieve the same
> effect in D? if not, what is recommended?

You don't - or at least it's generally inadvisable to try. Unlike C++, const 
in D is transitive. If something in D is const, it really is const. Take a 
look at this question/answer on stackoverflow:

http://stackoverflow.com/questions/4219600/logical-const-in-d

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list