r/cpp • • Mar 02 '26

Devirtualization and Static Polymorphism

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

6 comments sorted by

View all comments

Show parent comment

1

u/matthieum Mar 10 '26

I believe GCC is smart enough to elide the fallback case if the class is defined in anonymous namespace, which prevents subclassing in a different TU.

Bit limited, admittedly.