Allow using Bind() with non-public inheritance in C++11 code
Using Bind() with a method of the class deriving from wxEvtHandler non-publicly used to result in a compile-time error, but at least with C++11 we can detect this case and allow the code to compile. Closes #17623.
This commit is contained in:
@@ -509,3 +509,21 @@ void EvtHandlerTestCase::UnbindFromHandler()
|
||||
|
||||
handler.ProcessEvent(e);
|
||||
}
|
||||
|
||||
// This is a compilation-time-only test: just check that a class inheriting
|
||||
// from wxEvtHandler non-publicly can use Bind() with its method, this used to
|
||||
// result in compilation errors.
|
||||
// Note that this test will work only on C++11 compilers, so we test this only
|
||||
// for such compilers.
|
||||
#if __cplusplus >= 201103
|
||||
class HandlerNonPublic : protected wxEvtHandler
|
||||
{
|
||||
public:
|
||||
HandlerNonPublic()
|
||||
{
|
||||
Bind(wxEVT_IDLE, &HandlerNonPublic::OnIdle, this);
|
||||
}
|
||||
|
||||
void OnIdle(wxIdleEvent&) { }
|
||||
};
|
||||
#endif // C++11
|
||||
|
Reference in New Issue
Block a user