[vlmc-devel] Singleton: Use C++11 way of preventing access to copy/move operations

Hugo Beauzée-Luyssen git at videolan.org
Mon Jul 4 15:34:26 CEST 2016


vlmc | branch: medialibrary | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Jun 21 17:12:50 2016 +0200| [a20d182e7dcf5040a8f6e63b3e3e59837fd676bb] | committer: Hugo Beauzée-Luyssen

Singleton: Use C++11 way of preventing access to copy/move operations

> https://code.videolan.org/videolan/vlmc/commit/a20d182e7dcf5040a8f6e63b3e3e59837fd676bb
---

 src/Tools/Singleton.hpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/Tools/Singleton.hpp b/src/Tools/Singleton.hpp
index 587726b..9ac7071 100644
--- a/src/Tools/Singleton.hpp
+++ b/src/Tools/Singleton.hpp
@@ -25,8 +25,7 @@
   * This file contain the templated singleton.
   * Class/struct to be singletonized just have to
   * iherit from this classe with the class/struct type in template
-  * parameter.You have to do few other things, but you know your job,
-  * don't you? :)
+  * parameter.
   */
 
 #ifndef SINGLETON_HPP
@@ -55,10 +54,11 @@ public:
     }
 protected:
     Singleton(){}
-    virtual ~Singleton(){}
-    //Not implemented since these methods should *NEVER* been called. If they do, it probably won't compile :)
-    Singleton(const Singleton<T>&);
-    Singleton<T>&   operator=(const Singleton<T>&);
+    ~Singleton() = default;
+    Singleton(const Singleton<T>&) = delete;
+    Singleton(Singleton<T>&&) = delete;
+    Singleton<T>&   operator=(const Singleton<T>&) = delete;
+    Singleton<T>&   operator=(Singleton<T>&&) = delete;
 
 protected:
     static T*      m_instance;



More information about the Vlmc-devel mailing list