4 ms·
For the record, runtime polymorphism is generally frowned upon in the most modern C++ practice. The only difference between “modern, clean” C++ and the author’
by e-dant 4y ago
For the record, runtime polymorphism is generally frowned upon in the most modern C++ practice.
The only difference between “modern, clean” C++ and the author’s switch is probably a concept that requires some type attributes.
The example is contrived, and the realization of “clean” code through runtime polymorphism is both dangerous and odd. The whole point of not using polymorphism is to catch runtime crashes at compile time, reduce overhead and improve readability. I know many people who wouldn’t use an object here anyway. Free functions would do nicely, and are infinitely compositional.