4 ms·
Why C++ Member Function Pointers Are 16 Bytes Wide (2013)
- nly 12y agoSummary: the cost of multiple inheritance. Things get quite a bit more interesting when you have virtual inheritance in the mix. The most expensive call in C++ is a call through a member function pointer that points to a virtual member function declared in a virtual base class. The full assembly of such a call can be seen here on Godbolt: http://goo.gl/wql5Db http://goo.gl/wql5Db Here vtable slot 1 and an adjustment of 16 bytes (Derived -> BaseV) is returned, but the virtual call could (if not derived further) actually end up calling the thunk, which does a secondary adjustment (BaseV -> the Base2 in Derived), using an offset from Deriveds vtable, before finally jumping to the actual target.