digitalmars.D - How do I instantiate a class as invariant?
- Craig Black (10/10) Apr 02 2008 I can't figure out how to instantiate a class as invariant. The followi...
- Walter Bright (5/8) Apr 02 2008 You'll have to do a cast at some point. This isn't the most robust way
I can't figure out how to instantiate a class as invariant. The following code issues this error: cannot implicitly convert expression (new A) of type hello.A to invariant(A) class A {} int main(char[][] args) { invariant A a = new A; return 0; } -Craig
Apr 02 2008
Craig Black wrote:I can't figure out how to instantiate a class as invariant. The following code issues this error: cannot implicitly convert expression (new A) of type hello.A to invariant(A)You'll have to do a cast at some point. This isn't the most robust way as the compiler won't be able to check if it really is invariant, and we are working on some ideas to improve it, but that's the way it is at the moment.
Apr 02 2008