// If, at any point (in user code), Singleton<T>::instance()
    //  is called, then the following function is instantiated.
    static void do_initialize()
    {
        // call the static function
        T::initialize();

        // The following line does nothing else than force the instantiation
        //  of Singleton<T>::create_object, whose constructor is
        //  called before main() begins.
        create_object.do_nothing();
    }
Beispiel #2
0
			// 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;
			}
Beispiel #3
0
 static object_type & instance() {
   static object_type obj;
   create_object.do_nothing();
   return obj;
 }