// If, at any point (in user code), singleton_default<T>::instance() // is called, then the following function is instantiated. static object_type & instance() { // This is the object that we return a reference to. // It is guaranteed to be created before main() begins because of // the next line. static object_type obj; // The following line does nothing else than force the instantiation // of singleton_default<T>::create_object, whose constructor is // called before main() begins. create_object.do_nothing(); return obj; }
static object_type & instance() { static object_type obj; create_object.do_nothing(); return obj; }