Fully transitive const is not necessary

Janice Caron caron800 at googlemail.com
Wed Apr 2 07:15:20 PDT 2008


On 02/04/2008, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
> "Janice Caron" wrote
>  > pure requires transitive const.
>
>  Forgive me if I don't take your word for it.  Please prove this.
>  Specifically, why pure fails with logical const (not head const as C++ is).

    class Stupid
    {
        int x;
        mutable int y;
    }

    not_pure void f(const(Stupid) stupid) const
    {
        int t = y;
        ++t;
        y = t;
    }

Try calling f from two threads at the same time, imagine a thread
switch partway through f.



More information about the Digitalmars-d mailing list