From a7ab08498cb4c607225908453154805458c5e815 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 17 Feb 2020 23:53:08 +0300 Subject: [PATCH] Comments (before the code will be removed completely) --- libs/libcommon/include/ext/singleton.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libs/libcommon/include/ext/singleton.h b/libs/libcommon/include/ext/singleton.h index ed4be05de09..8392ae7fc01 100644 --- a/libs/libcommon/include/ext/singleton.h +++ b/libs/libcommon/include/ext/singleton.h @@ -2,7 +2,15 @@ #include -namespace ext { +namespace ext +{ + +/** Thread-unsafe singleton. It works simply like a global variable. + * Supports deinitialization. + * + * In most of the cases, you don't need this class. + * Use "Meyers Singleton" instead: static T & instance() { static T x; return x; } + */ template class Singleton @@ -11,14 +19,7 @@ public: Singleton() { if (!instance) - instance.reset(new T); - } - - template - Singleton(const Args & ... args) - { - instance.reset(new T(args...)); - /// TODO: throw exception on double-creation. + instance = std::make_unique(); } T * operator->()