Use macros to define default copy constructor and assignment operator

This commit is contained in:
Maarten Bent
2020-04-13 15:05:29 +02:00
parent 287c1b1d11
commit 1448b210b8
5 changed files with 35 additions and 12 deletions

View File

@@ -38,10 +38,7 @@ public:
wxAnimation();
explicit wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY);
#ifdef wxHAS_MEMBER_DEFAULT
wxAnimation(const wxAnimation&) wxMEMBER_DEFAULT;
wxAnimation& operator=(const wxAnimation&) wxMEMBER_DEFAULT;
#endif
wxDECLARE_DEFAULT_COPY_CLASS(wxAnimation);
bool IsOk() const;
bool IsCompatibleWith(wxClassInfo* ci) const;

View File

@@ -290,13 +290,10 @@ typedef short int WXTYPE;
still requires handling MSVS specially, unfortunately) */
#if __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(14)
#define wxHAS_MEMBER_DEFAULT
#define wxMEMBER_DEFAULT = default
#define wxHAS_NOEXCEPT
#define wxNOEXCEPT noexcept
#else
#define wxMEMBER_DEFAULT
#define wxNOEXCEPT
#endif
@@ -3042,6 +3039,22 @@ typedef const void* WXWidget;
#define DECLARE_NO_ASSIGN_CLASS(classname) \
wxDECLARE_NO_ASSIGN_CLASS(classname);
/* --------------------------------------------------------------------------- */
/* macros to define a class with default copy constructor and/or assignment operator */
/* --------------------------------------------------------------------------- */
#ifdef wxHAS_MEMBER_DEFAULT
#define wxDECLARE_DEFAULT_COPY_CTOR(classname) \
classname(const classname&) = default
#define wxDECLARE_DEFAULT_COPY_CLASS(classname) \
wxDECLARE_DEFAULT_COPY_CTOR(classname); \
classname& operator=(const classname&) = default
#else
#define wxDECLARE_DEFAULT_COPY_CTOR(classname)
#define wxDECLARE_DEFAULT_COPY_CLASS(classname)
#endif
/* --------------------------------------------------------------------------- */
/* If a manifest is being automatically generated, add common controls 6 to it */
/* --------------------------------------------------------------------------- */

View File

@@ -267,9 +267,7 @@ public:
wxUniCharRef& operator=(const wxUniCharRef& c)
{ if (&c != this) *this = c.UniChar(); return *this; }
#ifdef wxHAS_MEMBER_DEFAULT
wxUniCharRef(const wxUniCharRef&) wxMEMBER_DEFAULT;
#endif
wxDECLARE_DEFAULT_COPY_CTOR(wxUniCharRef);
#define wxUNICHAR_REF_DEFINE_OPERATOR_EQUAL(type) \
wxUniCharRef& operator=(type c) { return *this = wxUniChar(c); }