Re: C++-style mutable members

2017-01-17 Thread Namespace via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 20:21:34 UTC, Nordlöw wrote: Is there a way to mimic C++-style `mutable` members in D? You could store a ptr to the member outside: import std.stdio; private int* _pid; struct A { int id; this(int id

Re: C++-style mutable members

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 20:50:34 UTC, Nordlöw wrote: On Tuesday, 17 January 2017 at 20:47:35 UTC, ketmar wrote: Is there a way to mimic C++-style `mutable` members in D? sure: don't use `const`. otherwise — no, there is simply no way to «mimic» 'em due to completely different

Re: C++-style mutable members

2017-01-17 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 20:47:35 UTC, ketmar wrote: Is there a way to mimic C++-style `mutable` members in D? sure: don't use `const`. otherwise — no, there is simply no way to «mimic» 'em due to completely different meaning of `const` in D and C++. I'm aware of the

Re: C++-style mutable members

2017-01-17 Thread ketmar via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 20:21:34 UTC, Nordlöw wrote: Is there a way to mimic C++-style `mutable` members in D? sure: don't use `const`. otherwise — no, there is simply no way to «mimic» 'em due to completely different meaning of `const` in D and C++.

C++-style mutable members

2017-01-17 Thread Nordlöw via Digitalmars-d-learn
Is there a way to mimic C++-style `mutable` members in D?