From 52ef7157e746c35cccb209630f4cb42944ee382a Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Tue, 7 Apr 2020 19:03:36 +0200 Subject: [PATCH] Define wxMEMBER_DEFAULT similarly to the existing wxOVERRIDE Also define wxHAS_MEMBER_DEFAULT allowing to check if '= default' is supported (compilers that define c++11 and VS2015 and later). --- docs/doxygen/mainpages/const_cpp.h | 3 +++ include/wx/animate.h | 6 +++--- include/wx/defs.h | 8 ++++++++ include/wx/unichar.h | 4 ++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/doxygen/mainpages/const_cpp.h b/docs/doxygen/mainpages/const_cpp.h index 2a23d7381e..75ffbad426 100644 --- a/docs/doxygen/mainpages/const_cpp.h +++ b/docs/doxygen/mainpages/const_cpp.h @@ -171,6 +171,9 @@ Currently the following symbols exist: wxBitmapToggleButton class is available in addition to wxToggleButton.} @itemdef{wxHAS_CONFIG_TEMPLATE_RW, Defined if the currently used compiler supports template Read() and Write() methods in wxConfig.} +@itemdef{wxHAS_MEMBER_DEFAULT, Defined if the currently used compiler supports + C++11 @c =default. @c wxMEMBER_DEFAULT is defined as this keyword in this + case, and as nothing otherwise.} @itemdef{wxHAS_LARGE_FILES, Defined if wxFile supports files more than 4GB in size (notice that you must include @c wx/filefn.h before testing for this symbol).} diff --git a/include/wx/animate.h b/include/wx/animate.h index f4de421c98..339303a639 100644 --- a/include/wx/animate.h +++ b/include/wx/animate.h @@ -38,9 +38,9 @@ public: wxAnimation(); explicit wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY); -#if __cplusplus >= 201103 - wxAnimation(const wxAnimation&) = default; - wxAnimation& operator=(const wxAnimation&) = default; +#ifdef wxHAS_MEMBER_DEFAULT + wxAnimation(const wxAnimation&) wxMEMBER_DEFAULT; + wxAnimation& operator=(const wxAnimation&) wxMEMBER_DEFAULT; #endif bool IsOk() const; diff --git a/include/wx/defs.h b/include/wx/defs.h index 9f3c3a810c..98d06650ba 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -285,6 +285,14 @@ typedef short int WXTYPE; #define wxOVERRIDE #endif /* HAVE_OVERRIDE */ +/* same for defaulted member function keyword */ +#if __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(14) + #define wxHAS_MEMBER_DEFAULT + #define wxMEMBER_DEFAULT = default +#else + #define wxMEMBER_DEFAULT +#endif + /* Support for nullptr is available since MSVS 2010, even though it doesn't define __cplusplus as a C++11 compiler. diff --git a/include/wx/unichar.h b/include/wx/unichar.h index 55d4006803..a7cb03079c 100644 --- a/include/wx/unichar.h +++ b/include/wx/unichar.h @@ -267,8 +267,8 @@ public: wxUniCharRef& operator=(const wxUniCharRef& c) { if (&c != this) *this = c.UniChar(); return *this; } -#if __cplusplus >= 201103 - wxUniCharRef(const wxUniCharRef&) = default; +#ifdef wxHAS_MEMBER_DEFAULT + wxUniCharRef(const wxUniCharRef&) wxMEMBER_DEFAULT; #endif #define wxUNICHAR_REF_DEFINE_OPERATOR_EQUAL(type) \