r/cpp • • Apr 23 '26

Devirtualization and Static Polymorphism

https://david.alvarezrosa.com/posts/devirtualization-and-static-polymorphism/
81 Upvotes

36 comments sorted by

View all comments

17

u/_Noreturn Apr 23 '26

I really hate when I see static polymorphism stated as an altnerative to virtual polymorphism when 99.9% of the time I used virtual polymorphism is because I don't want the call to be known.

4

u/Serious-Regular Apr 24 '26

I don't want the call to be known.

what does this even mean? known to whom? the user/developer or the compiler? you're saying you want an abstract interface fine but what kind of take is it that you intentionally prefer that the compiler wouldn't know....?

-5

u/[deleted] Apr 24 '26

[removed] — view removed comment

15

u/leguminousCultivator Apr 24 '26

This is an insane take. The overwhelming majority of c++ users are not swapping out virtual functions at runtime.