> - Doesn't act transparently as a int subclass; > - Syntax-wise it's longer to define; > - The invariant is not enforced in all situations.
And the compiler in most situations doesn't "run" the invariant at compile time (unless you define an enum). Well, a test shows that it doesn't work (dmd 2.048) even if you use enum, I don't know why: struct Foo { int x; this(int y) { this.x = y; } } void main() { enum Foo f = Foo(1); } Bye, bearophile