Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  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.


It 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.


Actually you can do it using template but it is quite convoluted. (http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.130....)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: