diff --git a/docs/changes.txt b/docs/changes.txt index 0612f427a5..66038b4877 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -550,6 +550,7 @@ All: - Add wxFile::ReadAll() for consistency with wxFFile. - Add wxDateTime::DiffAsDateSpan() and wxDateSpan::GetTotalMonths() (jonasr). - Add wxVector::assign() (Jonas Rydberg). +- Add wxNOEXCEPT (Marian VooDooMan Meravy). - Added Nepali translation (Him Prasad Gautam). All (GUI): diff --git a/include/wx/defs.h b/include/wx/defs.h index a96a6e91f4..a3a08d026f 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -3335,6 +3335,17 @@ typedef const void* WXWidget; #define DECLARE_NO_ASSIGN_CLASS(classname) \ wxDECLARE_NO_ASSIGN_CLASS(classname); +/* Macro that can be used to indicate that a function doesn't throw. */ +#if defined(__cplusplus) && __cplusplus >= 199711L /* C++98 */ +# if __cplusplus >= 201103L /* >= C++11 */ +# define wxNOEXCEPT noexcept +# else +# define wxNOEXCEPT throw() +# endif +#else +# define wxNOEXCEPT +#endif + /* --------------------------------------------------------------------------- */ /* If a manifest is being automatically generated, add common controls 6 to it */ /* --------------------------------------------------------------------------- */ diff --git a/include/wx/msw/textctrl.h b/include/wx/msw/textctrl.h index c56bcae45a..f80eef03b2 100644 --- a/include/wx/msw/textctrl.h +++ b/include/wx/msw/textctrl.h @@ -31,7 +31,7 @@ public: Create(parent, id, value, pos, size, style, validator, name); } - virtual ~wxTextCtrl(); + virtual ~wxTextCtrl() wxNOEXCEPT; bool Create(wxWindow *parent, wxWindowID id, const wxString& value = wxEmptyString, diff --git a/include/wx/stdstream.h b/include/wx/stdstream.h index 27d48d5c8b..cc65cc34f1 100644 --- a/include/wx/stdstream.h +++ b/include/wx/stdstream.h @@ -28,7 +28,7 @@ class WXDLLIMPEXP_BASE wxStdInputStreamBuffer : public std::streambuf { public: wxStdInputStreamBuffer(wxInputStream& stream); - virtual ~wxStdInputStreamBuffer() { } + virtual ~wxStdInputStreamBuffer() wxNOEXCEPT { } protected: virtual std::streambuf *setbuf(char *s, std::streamsize n); @@ -71,7 +71,7 @@ class WXDLLIMPEXP_BASE wxStdInputStream : public std::istream { public: wxStdInputStream(wxInputStream& stream); - virtual ~wxStdInputStream() { } + virtual ~wxStdInputStream() wxNOEXCEPT { } protected: wxStdInputStreamBuffer m_streamBuffer; @@ -85,7 +85,7 @@ class WXDLLIMPEXP_BASE wxStdOutputStreamBuffer : public std::streambuf { public: wxStdOutputStreamBuffer(wxOutputStream& stream); - virtual ~wxStdOutputStreamBuffer() { } + virtual ~wxStdOutputStreamBuffer() wxNOEXCEPT { } protected: virtual std::streambuf *setbuf(char *s, std::streamsize n); @@ -112,7 +112,7 @@ class WXDLLIMPEXP_BASE wxStdOutputStream : public std::ostream { public: wxStdOutputStream(wxOutputStream& stream); - virtual ~wxStdOutputStream() { } + virtual ~wxStdOutputStream() wxNOEXCEPT { } protected: wxStdOutputStreamBuffer m_streamBuffer; diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index d4780cc987..dcf0311b74 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -679,7 +679,7 @@ public: // -------- wxTextCtrlBase() { } - virtual ~wxTextCtrlBase() { } + virtual ~wxTextCtrlBase() wxNOEXCEPT { } // more readable flag testing methods diff --git a/interface/wx/defs.h b/interface/wx/defs.h index 0c310f10d2..43b41fb971 100644 --- a/interface/wx/defs.h +++ b/interface/wx/defs.h @@ -1725,6 +1725,22 @@ template wxSwap(T& first, T& second); */ void wxVaCopy(va_list argptrDst, va_list argptrSrc); +/** + Macro that can be used to indicate that a function doesn't throw any + exceptions. + + This macro expands to `noexcept` when using C++11 compiler or `throw()` for + older C++ compilers or nothing when used with a C++ compiler too old to + support even this. + + Notice that `noexcept` and `throw()` have different semantics in case an + exception @e is thrown, so this macro should be used only if you don't rely + on the behaviour provided by the latter but not the former. + + @since 2.9.5 + */ +#define wxNOEXCEPT + //@} diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index ac476a5add..d8d2915f10 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -940,7 +940,7 @@ class wxComboCtrlTextCtrl : public wxTextCtrl { public: wxComboCtrlTextCtrl() : wxTextCtrl() { } - virtual ~wxComboCtrlTextCtrl() { } + virtual ~wxComboCtrlTextCtrl() wxNOEXCEPT { } virtual wxWindow *GetMainWindowOfCompositeControl() { diff --git a/src/generic/spinctlg.cpp b/src/generic/spinctlg.cpp index 64d00b43ff..f602d8ded5 100644 --- a/src/generic/spinctlg.cpp +++ b/src/generic/spinctlg.cpp @@ -77,7 +77,7 @@ public: SetSizeHints(wxDefaultCoord, wxDefaultCoord); } - virtual ~wxSpinCtrlTextGeneric() + virtual ~wxSpinCtrlTextGeneric() wxNOEXCEPT { // MSW sends extra kill focus event on destroy if (m_spin)