r/cpp • u/victor-s8n • 26d ago
How I design C++ classes
https://rafb.eu/blog/cpp-class-design/This is my first ever blog-post, any feedback is welcome! ofc, no AI got used.
66
Upvotes
r/cpp • u/victor-s8n • 26d ago
This is my first ever blog-post, any feedback is welcome! ofc, no AI got used.
View all comments
Show parent comment
2
u/victor-s8n 22d ago
You can set the impl methonds to `final` https://en.cppreference.com/cpp/language/final . In doing so the compiler can reason better about the v-table.
Over the past years I learned that 95% of the code is not executed very often. There is a 5% hotpath, but you, know, measure first. For the other 95% of the code, it's about maintainability, testablilty, and yes, compilation-time.
yes "Non-virtual functions are testable".
It's C++.
EVERYTHING is possible, which leads to projects being unmaintainable. I think this makes C++ unpopular. This thinking of the few nanoseconds that one can strip off, by optimizing a `virtual`. Code that only runs once when eg parsing a config-file.