Boost logo

Boost :

Subject: Re: [boost] [type_index] Interest in dynamic_cast emulation?
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-07-14 19:02:25


On 15/07/2016 00:13, Chris Glover wrote:
> I reached for Boost.TypeIndex the other day expecting to find a kind of
> dynamic_cast I could use in the absence of Rtti. I didn't find it, so I
> wrote something to emulate it using type_index internally.
>
> It's working, but before I go too far and clean this up and possibly submit
> a pull request, I would like to gauge if there's interest in such a thing
> or if there's some fundamental reason why it doesn't exist.

If you're writing the sort of program that needs dynamic_casts, I would
question why you have RTTI turned off in the first place. The compiler
ought to be able to implement it more efficiently than a library can.

Also I'm curious whether there are limitations on your implementation.
Does it support casts to intermediate types (not just the actual type),
casts in multi-inheritance hierarchies, casts in virtual base
hierarchies, etc?


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