Skip to content

Get rid of SingletonHolder #3890

@obiltschnig

Description

@obiltschnig

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;
}

Metadata

Metadata

Assignees

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions