#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_)
{
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_;
}
template <typename T> T* singleton<T>::ptr_ = 0;
+} // namespace dc
+
#endif // _SINGLETON_HH_
+/** vim: set ts=4 sw=4 tw=80: *************************************************/
+