Replacing with a higher-level abstraction:
• Singleton*
instance;
• Singleton* GetInstance() {
once {
instance = new T;
}
return instance;
}
And
allowing this variant:
• Singleton*
instance = new T;
• Singleton* GetInstance() {
return instance;
}
•Variables should only be initialized once, so we should require the compiler to implicitly Do the Right Thing.