From 3e05d92dcb5f6c2017bc462554901ba27816bdb4 Mon Sep 17 00:00:00 2001 From: George Hazan <ghazan@miranda.im> Date: Tue, 17 Apr 2018 15:56:52 +0300 Subject: MNonCopyable - the common class to avoid declaring fake private constructors --- include/m_chat_int.h | 4 ++-- include/m_system_cpp.h | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/m_chat_int.h b/include/m_chat_int.h index f3168a7fba..f366ca4052 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -399,8 +399,8 @@ EXTERN_C MIR_APP_DLL(LRESULT) CALLBACK stubNicklistProc(HWND hwnd, UINT msg, WPA class MIR_APP_EXPORT CSrmmBaseDialog : public CDlgBase { - CSrmmBaseDialog(const CSrmmBaseDialog&); - CSrmmBaseDialog& operator=(const CSrmmBaseDialog&); + CSrmmBaseDialog(const CSrmmBaseDialog&) = delete; + CSrmmBaseDialog& operator=(const CSrmmBaseDialog&) = delete; protected: CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si = nullptr); diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index b0f15305de..1135678859 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -45,7 +45,7 @@ public: __inline explicit mir_ptr(T *_p) : data(_p) {} __inline ~mir_ptr() { mir_free(data); } __inline T* get() const { return data; } - __inline T* operator = (T *_p) { if (data) mir_free(data); data = _p; return data; } + __inline T* operator=(T *_p) { if (data) mir_free(data); data = _p; return data; } __inline T* operator->() const { return data; } __inline operator T*() const { return data; } __inline operator INT_PTR() const { return (INT_PTR)data; } @@ -75,7 +75,7 @@ public: class mir_cslock { CRITICAL_SECTION &cs; - __inline mir_cslock& operator = (const mir_cslock&) { return *this; } + __inline mir_cslock& operator=(const mir_cslock&) { return *this; } public: __inline mir_cslock(CRITICAL_SECTION &_cs) : cs(_cs) { ::EnterCriticalSection(&cs); } @@ -91,7 +91,7 @@ public: __inline explicit pass_ptrA() : mir_ptr(){} __inline explicit pass_ptrA(char *_p) : mir_ptr(_p) {} __inline ~pass_ptrA() { zero(); } - __inline char* operator = (char *_p){ zero(); return mir_ptr::operator=(_p); } + __inline char* operator=(char *_p){ zero(); return mir_ptr::operator=(_p); } __inline void zero() { if (data) SecureZeroMemory(data, mir_strlen(data)); } @@ -103,7 +103,7 @@ public: __inline explicit pass_ptrW() : mir_ptr(){} __inline explicit pass_ptrW(wchar_t *_p) : mir_ptr(_p) {} __inline ~pass_ptrW() { zero(); } - __inline wchar_t* operator = (wchar_t *_p){ zero(); return mir_ptr::operator=(_p); } + __inline wchar_t* operator=(wchar_t *_p){ zero(); return mir_ptr::operator=(_p); } __inline void zero() { if (data) SecureZeroMemory(data, mir_wstrlen(data)*sizeof(wchar_t)); } @@ -146,6 +146,17 @@ public: /////////////////////////////////////////////////////////////////////////////// // general lists' templates +struct MNonCopyable +{ + MNonCopyable() {} + + MNonCopyable(const MNonCopyable&) = delete; + MNonCopyable& operator=(const MNonCopyable&) = delete; +}; + +/////////////////////////////////////////////////////////////////////////////// +// general lists' templates + #define NumericKeySortT -1 #define HandleKeySortT -2 #define PtrKeySortT -3 -- cgit v1.2.3