How do I instantiate a class as invariant?

Walter Bright newshound1 at digitalmars.com
Wed Apr 2 23:56:02 PDT 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.



More information about the Digitalmars-d mailing list