From: Mikko Rasa Date: Wed, 25 Apr 2018 10:15:43 +0000 (+0300) Subject: Add a NonCopyable utility base class X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=3169ab5078b0ab9147b8e23ad98c0294dda1baec;p=libs%2Fcore.git Add a NonCopyable utility base class --- 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