From 3169ab5078b0ab9147b8e23ad98c0294dda1baec Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 25 Apr 2018 13:15:43 +0300 Subject: [PATCH] Add a NonCopyable utility base class --- source/core/noncopyable.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 source/core/noncopyable.h diff --git a/source/core/noncopyable.h b/source/core/noncopyable.h new file mode 100644 index 0000000..b3dfca3 --- /dev/null +++ b/source/core/noncopyable.h @@ -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 -- 2.45.2