Const struct syntax

bearophile bearophileHUGS at lycos.com
Tue Aug 30 04:08:32 PDT 2011


DMD 2.055head gives no compile-time errors on this, is this expected and good/acceptable?


struct Foo {
    int x;
    this(int x_) { this.x = x_; }
}
void main() {
    auto f1 = new const(Foo)(1);
    f1.x++;
    auto f2 = new immutable(Foo)(1);
    f2.x++;
    auto f3 = const(Foo)(1);
    f3.x++;
    auto f4 = immutable(Foo)(1);
    f4.x++;
}


Bye and thank you,
bearophile


More information about the Digitalmars-d-learn mailing list