Casting const/invariant

Janice Caron caron800 at googlemail.com
Wed Jan 2 22:54:59 PST 2008


On 1/3/08, Daniel919 <Daniel919 at web.de> wrote:
> When creating a new invariant struct/class, the compiler can always
> infer a cast(invariant).
> invariant clFoo foo = /*cast(invariant)*/ new clFoo();

I don't believe that is true. Consider

    class C
    {
        int *p;
        this() { p = &some_global_variable; }
    }

I don't see anything to stop *C.p from being modified by another means.



More information about the Digitalmars-d mailing list