How do I create a module-local immutable class object?
Andrej Mitrovic
andrej.mitrovich at gmail.com
Fri Sep 9 14:34:31 PDT 2011
I need to have an object which is initialized only once, so I thought
I could use immutable for that. But I can't do this:
private class Foo {}
immutable Foo foo;
static this()
{
foo = new Foo;
}
void main() {}
And I can't new the object when it's declared. Even if CTFE could new
objects, it wouldn't be possible because the ctor depends on API
calls.
More information about the Digitalmars-d-learn
mailing list