Boost logo

Boost :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2005-10-12 18:09:20


On Oct 12, 2005, at 4:28 PM, Andreas Pokorny wrote:

> Hi Doug,
>
> On Wed, Oct 12, 2005 at 01:43:36PM -0500, Doug Gregor
> <dgregor_at_[hidden]> wrote:
>>> I dont see why any_cast is used here at all. The type safety
>>> is guranteed by the interface of Boost.Signals, so I doubt that
>>> someone will be able to abuse the library. I believe the author
>>> of that code had the same in mind, since he did not test
>>> target != 0 before invoking the target. So in my opinion a
>>> simple reinterpret_cast should suffice here. It would also
>>> fix our issue, although that one is caused by gcc.
>>
>> You're right. Our options are:
>>
>> 1) Fix any_cast to compare typeid().name() instead of type_info
>> objects
>> 2) Make an unsafe_any_cast that doesn't do the check
>> 3) Switch signals to use void*'s
>>
>> For 1.33.1, I like #2 best because it affects the least amount of
>> code.
>> For 1.34.0 and beyond, #1 is probably our best bet so that others
>> don't
>> run into the same problem.
>
> Hm #1 does not sound good, it would make the cast even slower. I
> do not see a reason for dynamic typing here at all. #3 sounds good to
> me.

So long as we're careful about deallocating the memory at the right
time, sure; boost::any makes that kind of thing very, very easy.

        Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk