Add a NonCopyable utility base class
authorMikko Rasa <tdb@tdb.fi>
Wed, 25 Apr 2018 10:15:43 +0000 (13:15 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 25 Apr 2018 10:15:43 +0000 (13:15 +0300)
source/core/noncopyable.h [new file with mode: 0644]

diff --git a/source/core/noncopyable.h b/source/core/noncopyable.h
new file mode 100644 (file)
index 0000000..b3dfca3
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef MSP_CORE_NONCOPYABLE_H_
+#define MSP_CORE_NONCOPYABLE_H_
+
+namespace Msp {
+
+class NonCopyable
+{
+#if __cplusplus >= 201103L
+protected:
+       NonCopyable() = default;
+       NonCopyable(const NonCopyable &) = delete;
+       NonCopyable &operator=(const NonCopyable &) = delete;
+       ~NonCopyable() = default;
+#else
+private:
+       NonCopyable(const NonCopyable &) { }
+       NonCopyable &operator=(const NonCopyable &) { }
+protected:
+       NonCopyable() { }
+       ~NonCopyable() { }
+#endif
+};
+
+} // namespace Msp
+
+#endif