Fully transitive const is not necessary
Janice Caron
caron800 at googlemail.com
Wed Apr 2 12:06:48 PDT 2008
On 02/04/2008, Christian Kamm
<kamm.incasoftware at shift-at-left-and-remove-this.de> wrote:
> Steven is arguing that thread safety does not require transitive const
> guarantees.
> <snip>
Thank you. That was a perfect explanation. I get it now.
> class C
> {
> mutable int x;
> void foo() const { x++; } // const but can't be pure
> void bar() pure
> { /* can't do anything in here you couldn't have done above */ }
> }
But you could equally well write it like this:
class C
{
int x;
void foo() { x++; }
void bar() pure
{ /* can't do anything in here you couldn't have done above */ }
}
If it can change, then don't call it const. Seems a simple enough rule to me.
More information about the Digitalmars-d
mailing list