4 ms·
a) How can you make standard-OOP-like method dispatch faster than vtables? He doesn't claim you can: he just points out that it still adds overhead.
by Confusion 15y ago
a) How can you make standard-OOP-like method dispatch
faster than vtables?
He doesn't claim you can: he just points out that it still adds overhead.
- vidarh 15y agoIt only adds overhead when using virtual member functions, in which case the equivalent in C is to "roll your own" vtables. You don't get away from that overhead. If you don't use polymorphism, you don't need virtual member functions, in which case you don't pay the cost of a vtable. This is one of the key tenets of C++: You pay for what you use, and only what you use.
- zeugma 15y agoActually you can do it using template but it is quite convoluted. (http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.130.8620 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.130....)