Boost logo

Boost Users :

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


Hmm now that I think about it, I don't think this is really possible at
compile time. You have to consider issues like multiple bases (Through
either a linear chain of inheritance, or multiple inheritance cases).
If there were only a way to simplify this. Specifying the base class in two
places is obviously error-prone, and I am hoping there are other solutions
to cleaning this up.

On Tue, Jun 9, 2009 at 1:36 PM, Robert Dailey <rcdailey_at_[hidden]> wrote:

> 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