Boost logo

Boost Users :

Subject: [Boost-users] Obtaining base class type
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2009-06-09 14:36:31


Hey everyone,
I'm using wxWidgets, and as you all may know they have a silly macro used to
define an event table...

BEGIN_EVENT_TABLE( MainWindow, wxFrame )
   EVT_CLOSE( MainWindow::OnClose )
END_EVENT_TABLE()

I spend a few hours finding out that wxFrame is the incorrect parameter for
parameter #2. This is not the base class that MainWindow derives from. There
was no compiler error or warning, nor any errors during runtime. Only weird
behavior because events were getting skipped.

Because of this error-proneness, I'm looking for a way to have boost help me
out with this. I'm looking for a metafunction in Boost that can be used to
obtain (at compile time) the base type of MainWindow. For example:

BEGIN_EVENT_TABLE( MainWindow, boost::get_base_of<MainWindow>::type )
   EVT_CLOSE( MainWindow::OnClose )
END_EVENT_TABLE()

Something like that above. I know that type traits has is_base_of, and I'm
hoping there is a get version of that too. I've browsed through the
reference but I've found nothing helpful.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net