I believe all of these static assertions (and some variants thereof) should pass, due to the semantics of const, immutable, and shared.

immutable struct Immutable { }
const struct Const { }
shared struct Shared { }
static assert(is(Immutable == immutable(Immutable)));
static assert(is(Immutable == const(Immutable)));
static assert(is(Immutable == shared(Immutable)));
static assert(is(Const == const(Const)));
static assert(is(Const == shared(Const)));
static assert(is(Shared == shared(Shared)));


Do people agree?

Also, what exactly is the difference between declaring a struct as immutable or as const? Aren't they unmodifiable either way?

Reply via email to