diff --git a/include/wx/anystr.h b/include/wx/anystr.h index b2740bc172..fb71504990 100644 --- a/include/wx/anystr.h +++ b/include/wx/anystr.h @@ -134,7 +134,7 @@ private: const wxString * const m_str; const wxString::const_iterator m_iter; - wxDECLARE_NO_ASSIGN_CLASS(wxAnyStrPtr); + wxDECLARE_NO_ASSIGN_DEF_COPY(wxAnyStrPtr); }; #endif // _WX_ANYSTR_H_ diff --git a/include/wx/clrpicker.h b/include/wx/clrpicker.h index 77ae61ab66..0917ff627b 100644 --- a/include/wx/clrpicker.h +++ b/include/wx/clrpicker.h @@ -183,7 +183,7 @@ public: private: wxColour m_colour; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxColourPickerEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxColourPickerEvent); }; // ---------------------------------------------------------------------------- diff --git a/include/wx/cmdline.h b/include/wx/cmdline.h index c2b4a10e69..729ac0cb21 100644 --- a/include/wx/cmdline.h +++ b/include/wx/cmdline.h @@ -176,7 +176,7 @@ public: private: const wxCmdLineParser& m_parser; - wxDECLARE_NO_ASSIGN_CLASS(wxCmdLineArgs); + wxDECLARE_NO_ASSIGN_DEF_COPY(wxCmdLineArgs); }; // ---------------------------------------------------------------------------- diff --git a/include/wx/collpane.h b/include/wx/collpane.h index 168dc7c06e..9965463e63 100644 --- a/include/wx/collpane.h +++ b/include/wx/collpane.h @@ -92,7 +92,7 @@ public: private: bool m_bCollapsed; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCollapsiblePaneEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxCollapsiblePaneEvent); }; // ---------------------------------------------------------------------------- diff --git a/include/wx/colordlg.h b/include/wx/colordlg.h index 7fb04dd097..5e724f48f1 100644 --- a/include/wx/colordlg.h +++ b/include/wx/colordlg.h @@ -65,7 +65,7 @@ public: private: wxColour m_colour; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxColourDialogEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxColourDialogEvent); }; wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COLOUR_CHANGED, wxColourDialogEvent); diff --git a/include/wx/dateevt.h b/include/wx/dateevt.h index 8b1d424dfe..5354199b8b 100644 --- a/include/wx/dateevt.h +++ b/include/wx/dateevt.h @@ -39,7 +39,7 @@ public: private: wxDateTime m_date; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDateEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxDateEvent); }; // ---------------------------------------------------------------------------- diff --git a/include/wx/defs.h b/include/wx/defs.h index 400fce141a..81098fc9b8 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -3160,8 +3160,14 @@ typedef const void* WXWidget; #if defined(__cplusplus) && (__cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(14)) #define wxMEMBER_DELETE = delete + #define wxDECLARE_DEFAULT_COPY_CTOR(classname) \ + public: \ + classname(const classname&) = default; #else #define wxMEMBER_DELETE + + // We can't do this without C++11 "= default". + #define wxDECLARE_DEFAULT_COPY_CTOR(classname) #endif #define wxDECLARE_NO_COPY_CLASS(classname) \ @@ -3183,6 +3189,11 @@ typedef const void* WXWidget; private: \ classname& operator=(const classname&) wxMEMBER_DELETE +#define wxDECLARE_NO_ASSIGN_DEF_COPY(classname) \ + wxDECLARE_DEFAULT_COPY_CTOR(classname) \ + private: \ + classname& operator=(const classname&) wxMEMBER_DELETE + /* deprecated variants _not_ requiring a semicolon after them */ #define DECLARE_NO_COPY_CLASS(classname) \ wxDECLARE_NO_COPY_CLASS(classname); diff --git a/include/wx/dialog.h b/include/wx/dialog.h index 32db8b5b90..e56174c5b0 100644 --- a/include/wx/dialog.h +++ b/include/wx/dialog.h @@ -397,7 +397,7 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxWindowModalDialogEvent (*this); } private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowModalDialogEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxWindowModalDialogEvent); }; wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_WINDOW_MODAL_DIALOG_CLOSED , wxWindowModalDialogEvent ); diff --git a/include/wx/dialup.h b/include/wx/dialup.h index fab11359e4..1ffcc8e977 100644 --- a/include/wx/dialup.h +++ b/include/wx/dialup.h @@ -179,7 +179,7 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxDialUpEvent(*this); } private: - wxDECLARE_NO_ASSIGN_CLASS(wxDialUpEvent); + wxDECLARE_NO_ASSIGN_DEF_COPY(wxDialUpEvent); }; // the type of dialup event handler function diff --git a/include/wx/event.h b/include/wx/event.h index 2b3cad6bb7..5e58938644 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -1276,7 +1276,7 @@ protected: int m_commandInt; long m_extraLong; // Additional information (e.g. select/deselect) - wxDECLARE_NO_ASSIGN_CLASS(wxEventBasicPayloadMixin); + wxDECLARE_NO_ASSIGN_DEF_COPY(wxEventBasicPayloadMixin); }; class WXDLLIMPEXP_BASE wxEventAnyPayloadMixin : public wxEventBasicPayloadMixin @@ -1720,7 +1720,7 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxScrollEvent(*this); } private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxScrollEvent); }; // ScrollWin event class, derived fom wxEvent. wxScrollWinEvents @@ -2428,7 +2428,7 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxPaintEvent(*this); } private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaintEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxPaintEvent); }; class WXDLLIMPEXP_CORE wxNcPaintEvent : public wxEvent @@ -2444,7 +2444,7 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxNcPaintEvent(*this); } private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNcPaintEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxNcPaintEvent); }; // Erase background event class @@ -2520,7 +2520,7 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxChildFocusEvent(*this); } private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChildFocusEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxChildFocusEvent); }; // Activate event class @@ -2583,7 +2583,7 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxInitDialogEvent(*this); } private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxInitDialogEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxInitDialogEvent); }; // Miscellaneous menu event class @@ -2751,7 +2751,7 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxMaximizeEvent(*this); } private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMaximizeEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxMaximizeEvent); }; /* @@ -3052,7 +3052,7 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxSysColourChangedEvent(*this); } private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSysColourChangedEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxSysColourChangedEvent); }; /* @@ -3112,15 +3112,15 @@ public: */ class WXDLLIMPEXP_CORE wxDisplayChangedEvent : public wxEvent { -private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDisplayChangedEvent); - public: wxDisplayChangedEvent() : wxEvent(0, wxEVT_DISPLAY_CHANGED) { } virtual wxEvent *Clone() const wxOVERRIDE { return new wxDisplayChangedEvent(*this); } + +private: + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxDisplayChangedEvent); }; /* @@ -3153,7 +3153,7 @@ private: wxSize m_oldDPI; wxSize m_newDPI; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDPIChangedEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxDPIChangedEvent); }; /* @@ -3302,7 +3302,7 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxWindowCreateEvent(*this); } private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowCreateEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxWindowCreateEvent); }; class WXDLLIMPEXP_CORE wxWindowDestroyEvent : public wxCommandEvent @@ -3315,7 +3315,7 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxWindowDestroyEvent(*this); } private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowDestroyEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxWindowDestroyEvent); }; // A help event is sent when the user clicks on a window in context-help mode. diff --git a/include/wx/filectrl.h b/include/wx/filectrl.h index 51193716a3..d543958e3d 100644 --- a/include/wx/filectrl.h +++ b/include/wx/filectrl.h @@ -115,7 +115,7 @@ protected: wxString m_directory; wxArrayString m_files; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFileCtrlEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxFileCtrlEvent); }; typedef void ( wxEvtHandler::*wxFileCtrlEventFunction )( wxFileCtrlEvent& ); diff --git a/include/wx/filepicker.h b/include/wx/filepicker.h index 527e5282de..d97884271e 100644 --- a/include/wx/filepicker.h +++ b/include/wx/filepicker.h @@ -55,7 +55,7 @@ public: private: wxString m_path; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFileDirPickerEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxFileDirPickerEvent); }; wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILEPICKER_CHANGED, wxFileDirPickerEvent ); diff --git a/include/wx/fontpicker.h b/include/wx/fontpicker.h index 3c12f28783..8b3faef983 100644 --- a/include/wx/fontpicker.h +++ b/include/wx/fontpicker.h @@ -218,7 +218,7 @@ public: private: wxFont m_font; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFontPickerEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxFontPickerEvent); }; // ---------------------------------------------------------------------------- diff --git a/include/wx/fswatcher.h b/include/wx/fswatcher.h index 2030ee5434..700c92df2f 100644 --- a/include/wx/fswatcher.h +++ b/include/wx/fswatcher.h @@ -205,7 +205,7 @@ protected: wxFileName m_newPath; wxString m_errorMsg; private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFileSystemWatcherEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxFileSystemWatcherEvent); }; typedef void (wxEvtHandler::*wxFileSystemWatcherEventFunction) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index a936ce25a2..7e18047449 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -3244,7 +3244,7 @@ private: m_selecting = sel; } - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxGridEvent); }; class WXDLLIMPEXP_CORE wxGridSizeEvent : public wxNotifyEvent, @@ -3300,7 +3300,7 @@ private: m_y = y; } - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridSizeEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxGridSizeEvent); }; @@ -3365,7 +3365,7 @@ protected: wxGridCellCoords m_bottomRight; bool m_selecting; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridRangeSelectEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxGridRangeSelectEvent); }; @@ -3402,7 +3402,7 @@ private: int m_col; wxWindow* m_window; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEditorCreatedEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxGridEditorCreatedEvent); }; diff --git a/include/wx/generic/laywin.h b/include/wx/generic/laywin.h index d226766cf0..0066be9312 100644 --- a/include/wx/generic/laywin.h +++ b/include/wx/generic/laywin.h @@ -97,7 +97,7 @@ protected: wxLayoutAlignment m_alignment; private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxQueryLayoutInfoEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxQueryLayoutInfoEvent); }; typedef void (wxEvtHandler::*wxQueryLayoutInfoEventFunction)(wxQueryLayoutInfoEvent&); @@ -137,7 +137,7 @@ protected: wxRect m_rect; private: - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCalculateLayoutEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxCalculateLayoutEvent); }; typedef void (wxEvtHandler::*wxCalculateLayoutEventFunction)(wxCalculateLayoutEvent&); diff --git a/include/wx/html/htmlwin.h b/include/wx/html/htmlwin.h index aabb574f70..fe02c5a223 100644 --- a/include/wx/html/htmlwin.h +++ b/include/wx/html/htmlwin.h @@ -604,7 +604,7 @@ private: bool m_bLinkWasClicked; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHtmlCellEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxHtmlCellEvent); }; @@ -631,7 +631,7 @@ public: private: wxHtmlLinkInfo m_linkInfo; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHtmlLinkEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxHtmlLinkEvent); }; diff --git a/include/wx/hyperlink.h b/include/wx/hyperlink.h index 999f7d9740..d635f0350e 100644 --- a/include/wx/hyperlink.h +++ b/include/wx/hyperlink.h @@ -120,7 +120,7 @@ private: // URL associated with the hyperlink control that the used clicked on. wxString m_url; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHyperlinkEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxHyperlinkEvent); }; diff --git a/include/wx/process.h b/include/wx/process.h index bf32dd9281..21a1ccc157 100644 --- a/include/wx/process.h +++ b/include/wx/process.h @@ -179,7 +179,7 @@ public: int m_pid, m_exitcode; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxProcessEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxProcessEvent); }; typedef void (wxEvtHandler::*wxProcessEventFunction)(wxProcessEvent&); diff --git a/include/wx/rtti.h b/include/wx/rtti.h index 0f54a0b914..a30a3edb10 100644 --- a/include/wx/rtti.h +++ b/include/wx/rtti.h @@ -148,6 +148,10 @@ WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name); wxDECLARE_NO_ASSIGN_CLASS(name); \ wxDECLARE_DYNAMIC_CLASS(name) +#define wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(name) \ + wxDECLARE_NO_ASSIGN_DEF_COPY(name); \ + wxDECLARE_DYNAMIC_CLASS(name) + #define wxDECLARE_DYNAMIC_CLASS_NO_COPY(name) \ wxDECLARE_NO_COPY_CLASS(name); \ wxDECLARE_DYNAMIC_CLASS(name) diff --git a/include/wx/socket.h b/include/wx/socket.h index 4a66716984..971364c7e3 100644 --- a/include/wx/socket.h +++ b/include/wx/socket.h @@ -427,7 +427,7 @@ public: wxSocketNotify m_event; void *m_clientData; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSocketEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxSocketEvent); }; diff --git a/include/wx/taskbar.h b/include/wx/taskbar.h index 84e4a5c0b0..ca70ccaebc 100644 --- a/include/wx/taskbar.h +++ b/include/wx/taskbar.h @@ -110,7 +110,7 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxTaskBarIconEvent(*this); } private: - wxDECLARE_NO_ASSIGN_CLASS(wxTaskBarIconEvent); + wxDECLARE_NO_ASSIGN_DEF_COPY(wxTaskBarIconEvent); }; typedef void (wxEvtHandler::*wxTaskBarIconEventFunction)(wxTaskBarIconEvent&); diff --git a/include/wx/timer.h b/include/wx/timer.h index 42af63d9a9..1b60e6a84c 100644 --- a/include/wx/timer.h +++ b/include/wx/timer.h @@ -185,7 +185,7 @@ public: private: wxTimer* m_timer; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxTimerEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxTimerEvent); }; typedef void (wxEvtHandler::*wxTimerEventFunction)(wxTimerEvent&); diff --git a/include/wx/treelist.h b/include/wx/treelist.h index 5680c31547..ce9dba4599 100644 --- a/include/wx/treelist.h +++ b/include/wx/treelist.h @@ -515,7 +515,7 @@ private: friend class wxTreeListCtrl; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxTreeListEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxTreeListEvent); }; // Event types and event table macros. diff --git a/include/wx/webview.h b/include/wx/webview.h index 816b5a5ffc..e1af2b67ac 100644 --- a/include/wx/webview.h +++ b/include/wx/webview.h @@ -311,7 +311,7 @@ private: wxWebViewNavigationActionFlags m_actionFlags; wxString m_messageHandler; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWebViewEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxWebViewEvent); }; wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEBVIEW, wxEVT_WEBVIEW_NAVIGATING, wxWebViewEvent ); diff --git a/include/wx/wizard.h b/include/wx/wizard.h index 3048d75041..42277d7cd3 100644 --- a/include/wx/wizard.h +++ b/include/wx/wizard.h @@ -285,7 +285,7 @@ private: bool m_direction; wxWizardPage* m_page; - wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWizardEvent); + wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxWizardEvent); }; // ---------------------------------------------------------------------------- diff --git a/interface/wx/defs.h b/interface/wx/defs.h index 991500c10f..96fdf72a8c 100644 --- a/interface/wx/defs.h +++ b/interface/wx/defs.h @@ -1525,10 +1525,29 @@ typedef double wxDouble; In such case, this macro can be used to disable the automatic assignment operator generation. - @see wxDECLARE_NO_COPY_CLASS() + @see wxDECLARE_NO_COPY_CLASS(), wxDECLARE_NO_ASSIGN_DEF_COPY() */ #define wxDECLARE_NO_ASSIGN_CLASS(classname) +/** + Macro disabling the generation of default assignment operator but + generating a default copy constructor. + + This macro can be useful for the classes that can't be copied after + creation, but may be copy-constructed using the default compiler-generated + copy constructor. + + Note that using wxDECLARE_NO_ASSIGN_CLASS() for such macros results in @c + -Wdeprecated-copy warning from clang 13, while this macro avoids such + warnings. + + Default copy constructor is only generated when using C++11 or later, + otherwise this macro is identical to wxDECLARE_NO_ASSIGN_CLASS(). + + @since 3.1.6 + */ +#define wxDECLARE_NO_ASSIGN_DEF_COPY(classname) + /** This macro can be used in a class declaration to disable the generation of default copy ctor and assignment operator.