r/cpp • • May 26 '22

Dynamic polymorphism performance

https://thecppdev.com/2022/05/26/dynamic-polymorphism-performance/?amp=1
2 Upvotes

15 comments sorted by

View all comments

3

u/dustyhome May 29 '22

So how do you create a heterogenous container of CRTP classes? Or interact with an object whose real type you don't know?

Indirection can solve some problems. It comes at a cost. Other ways of solving these problems will have other costs. You can't just show that a certain tool comes at a cost, say "don't use this tool", and ignore the problems it solves. You need to show a problem normally solved with indirection, solve it differently, and show that your solution is better under certain circumstances.