On Thu, 14 Jul 2016 at 19:03 Gavin Lambert
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.
There are a couple of reasons for this. The first is that not all of our platforms support RTTI. This typically isn't a problem because we don't usually want to use RTTI on those platforms anyway, but there always end up being work arounds, such as people moving virtual functions to a base class in order to call it from one call site. Or adding things like bool IsFoo() to the base class, etc. The second is that we would prefer to opt in on a per hierarchy basis, rather than turn it on globally. In my opinion, depending on dynamic_cast is generally undesirable, but it can be useful to design you're hierarchies assuming dynamic_cast is available, at least for that hierarchy.
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?
I believe it works in all cases, but I'm not sure if my tests are comprehensive. One limitation might be performance, which you eluded to earlier, so I will write some tests for that as well. Since there seems to be at least some interest, I'm going to clean this up get to some eyes on it -- especially the tests. Thanks, -- chris