Would the following code facilitate lazy initialization?
Or would the singletonInstance
be created as soon as somebody includes the header
This is known as the Meyers singleton and they are lazy instantiated.
There are some considerations:
The SingletonClass
constructor will not be called earlier than somenone calls the Instance()
method.
Thus yes, it facilitates lazy initialization.