diff --git a/singleton.hpp b/singleton.hpp index 67d57835..304897d5 100644 --- a/singleton.hpp +++ b/singleton.hpp @@ -71,15 +71,25 @@ namespace cruft { } - /// returns a reference to sole instantiated value + /// Returns a reference to the instantiated value. /// - /// `instantiate` must have already been called before `get` is called. + /// `instantiate` must have already been called before `get` is called + /// otherwise the results are undefined. static SelfT& get (void) { CHECK (instance); return *instance; } + + + /// returns a pointer to the instantiated value if it exists, else we + /// return nullptr. + static SelfT* + maybe (void) + { + return instance; + } }; };