Re: [sigc] Range over signals



On Tue, 2005-11-29 at 14:56 +0100, Dick Eimers wrote:
> > A dynamic_cast<> should allow this. You'd need lots of them, in an
> > if/else-if block, for each sigc::signal<> type that you expect.
> 
> It turns out that the dynamic_cast fails because sigc::signal_base has
> no virtual functions (not even a virtual destructor).

That's interesting, and a pity if it's true.

>  And, of course,
> at least one virtual function needs to be defined in a class to be able
> to use the dynamic_cast<> cast.
> 
> The reason is probably to optimize for speed, but is it really that
> important and more important than being extensible and allow for
> type-safe downcasting? 

People do get obsessed with optimisation, yes. But, anyway, we couldn't
change this now, without breaking ABI.

I suggest that you 
a) Store a second piece of information alongside each signal,
identifying the signal type.
b) Use static_cast<>, after you've discovered what the type is.

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]