Is this a good singleton?

Vladde Nordholm via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Feb 13 10:58:57 PST 2016


Hello. I have this singleton,

------------------------------------------------------
class Singleton
{
     private this() {}
     static __gshared typeof(this) instance = new this;
}
------------------------------------------------------

and I wonder if it has any weaknesses. Or is there a better way 
to make a Singleton?

,vladde,


More information about the Digitalmars-d-learn mailing list