Re:Operation Costs in CPU Clock Cycles
by chrisseaton on Friday November 11, 2016 @05:03PM
(#12934899)
Is it that simple for virtual methods in complex class hierarchies? If the class hierarchy isn't linear, how can you assign simple absolute vtable indices for methods?
[ Parent
| on HN ]
Yes it is. The C++ ABI defines how any permitted inheritance hierarchy is mapped into a surjective, ordered set of vtables. Also, calls into methods of other classes in the hierarchy offset the this pointer accordingly.
It feels counterintuitive that these two mechanisms are sufficient; but they are.