-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
Since C++11, initialization of local static variables is thread-safe even in Visual C++.
This means we can get rid of SingletonHolder
and the singleton initialization pattern:
namespace
{
static SingletonHolder<Thingy> sh;
}
Thingy& SomeSingleton::defaultThingy()
{
return *sh.get();
}
This can be replaced with:
Thingy& SomeSingleton::defaultThingy()
{
static Thingy thingy;
return thingy;
}