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
16
u/User_Deprecated Apr 24 '26
`final` is usually the easy win, one keyword and the compiler handles the rest. In my experience though the bigger gain from CRTP is that once the call inlines, the optimizer suddenly sees the whole path. Constant propagation, dead branches, all that stuff starts firing. With a vtable boundary the compiler usually loses most of that visibility.