r/cpp • u/david-alvarez-rosa • Apr 23 '26
Devirtualization and Static Polymorphism
https://david.alvarezrosa.com/posts/devirtualization-and-static-polymorphism/
81
Upvotes
r/cpp • u/david-alvarez-rosa • Apr 23 '26
View all comments
Show parent comment
10
u/_Noreturn Apr 24 '26
I don't want it known at runtime, for swapping out types or storing many inside 1 container.
using crtp makes this annoying to do and using a std::variant would make the types hard coded limitting who can extend it.
Also virtual functions help in binary sizes and can hide things using Pimpl