#virtual-functions
2 posts tagged #virtual-functions.
One word, final, turns a virtual call into two instructions
A C++ Weekly episode reminded everyone of a free win: marking a class final lets the compiler devirtualize. We took the canonical example to GCC 16.1 at -O2 and read the actual assembly. Without final, GCC hedges with a runtime vtable check; with final, the whole call folds to mov eax, 42; ret. The asm is the proof.
Profiles take shape, and the contract C++26 left behind comes back
The other half of the Brno safety story: a profiles framework with real syntax (attributes, not pragmas) plus two concrete profiles from Stroustrup, and P3097 bringing virtual-function contracts back after they were cut from the C++26 MVP. All target C++29.