Allow using noexcept methods with event tables macros

Explicitly remove noexcept before static-casting the member function
pointer to the base class pointer type to avoid compilation error with
C++17.

Add a test checking that this does work now.

Closes #18721.
This commit is contained in:
Vadim Zeitlin
2020-04-09 19:48:59 +02:00
parent f4f70102ea
commit c3810da549
2 changed files with 42 additions and 1 deletions

View File

@@ -122,6 +122,9 @@ public:
void OnEvent(wxEvent&) { g_called.method = true; }
void OnAnotherEvent(AnotherEvent&);
void OnIdle(wxIdleEvent&) { g_called.method = true; }
#ifdef wxHAS_NOEXCEPT
void OnIdleNoExcept(wxIdleEvent&) noexcept { }
#endif
private:
wxDECLARE_EVENT_TABLE();
@@ -138,6 +141,10 @@ wxBEGIN_EVENT_TABLE(MyClassWithEventTable, wxEvtHandler)
EVT_MYEVENT(MyClassWithEventTable::OnMyEvent)
EVT_MYEVENT(MyClassWithEventTable::OnEvent)
#ifdef wxHAS_NOEXCEPT
EVT_IDLE(MyClassWithEventTable::OnIdleNoExcept)
#endif
// this shouldn't compile:
//EVT_MYEVENT(MyClassWithEventTable::OnIdle)
//EVT_IDLE(MyClassWithEventTable::OnAnotherEvent)