I remember a couple years ago someone speaking of putting a singleton variable as a function static instead of a static pointer variable as a private member of the class.
However, since statics in functions aren't constructed until they are first approached, then somehow the code has to prevent it from reconstructing the singleton every single time a user calls GetInstance(). So what happens to the code?
static RenderManager& RenderManager::GetInstance()
{
static RenderManager renderManager;
return renderManager;
}
//Call GetInstance()
//Construct local static variable at some globally defined address
//return instance
//Call GetInstance() again
//---------- what instruction would go here? is it replaced with a "no-op"?
//Return instance