]> Dogcows Code - chaz/yoink/blobdiff - src/singleton.hh
big batch of progress
[chaz/yoink] / src / singleton.hh
index 3b2ebf73239719f419f374e22527c24492f3b9e0..ec0d01e9997fbce426c4f41a460e00540f81c66f 100644 (file)
 #include <stdexcept>
 
 
+namespace dc {
+
+
 template <typename T>
 class singleton
 {
        static T* ptr_;
 
 public:
+       struct exception : public std::runtime_error
+       {
+               explicit exception(const std::string& what_arg) :
+                       std::runtime_error(what_arg) {}
+       };
+
        singleton()
        {
                if (!ptr_)
@@ -60,12 +69,12 @@ public:
        {
                if (!ptr_)
                {
-                       throw std::runtime_error("accessing uninstantiated singleton");
+                       throw exception("accessing uninstantiated singleton");
                }
                return *ptr_;
        }
 
-       static T* instance__ptr()
+       static T* instance_ptr()
        {
                return ptr_;
        }
@@ -74,5 +83,9 @@ public:
 template <typename T> T* singleton<T>::ptr_ = 0;
 
 
+} // namespace dc
+
 #endif // _SINGLETON_HH_
 
+/** vim: set ts=4 sw=4 tw=80: *************************************************/
+
This page took 0.021632 seconds and 4 git commands to generate.