April 03, 2008 How do I instantiate a class as invariant? | ||||
|---|---|---|---|---|
| ||||
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
| ||||
April 03, 2008 Re: How do I instantiate a class as invariant? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Craig Black | 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.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply