Просмотр исходного кода

Common: Use C++11 deleted functions for NonCopyable

Yuri Kunde Schlesner 11 лет назад
Родитель
Сommit
7a4b717772
1 измененных файлов с 6 добавлено и 8 удалено
  1. 6 8
      src/common/common.h

+ 6 - 8
src/common/common.h

@@ -14,15 +14,13 @@
 #define STACKALIGN
 #define STACKALIGN
 
 
 // An inheritable class to disallow the copy constructor and operator= functions
 // An inheritable class to disallow the copy constructor and operator= functions
-class NonCopyable
-{
+class NonCopyable {
 protected:
 protected:
-    NonCopyable() {}
-    NonCopyable(const NonCopyable&&) {}
-    void operator=(const NonCopyable&&) {}
-private:
-    NonCopyable(NonCopyable&);
-    NonCopyable& operator=(NonCopyable& other);
+    NonCopyable() = default;
+    ~NonCopyable() = default;
+
+    NonCopyable(NonCopyable&) = delete;
+    NonCopyable& operator=(NonCopyable&) = delete;
 };
 };
 
 
 #include "common/assert.h"
 #include "common/assert.h"