Frederick Virchanza Gotham <
cauldwel...@gmail.com> wrote:
> I intend to manipulate the functionality of 'dynamic_cast' on x86_64 with the GNU compiler 'g++'.
dynamic_cast is a rather complicated feature.
Most C++ programmers think of it as "just a downcast with a check to see
that the current object is actually of the derived type we are casting to".
However, it supports more than just casting from a base class type to a
derived class type with a validity check. You can have a very complicated
diamond inheritance scenario involving a dozen classes up and down the
inheritance tree (and even multiple diamond shapes within this tree), and
you can dynamic_cast between any two class types within that tree, and it
will work (ie. it will check if the object in question actually is of, or
inherits from, the target class type, and correctly calculates the pointer
offset for that particular type within the current object, no matter where
in the complex diamond inheritance hierarcy the source and target types may
be.) And yes, this does involve traveling inheritance hierarchies up and
down (possibly with some optimizations).