Technical requirements
The Google Benchmark library: https://github.com/google/benchmark
Example code: https://github.com/PacktPublishing/Hands-On-Design-Patterns-with-CPP-Second-Edition/tree/master/Chapter08
Wrapping your head around CRTP
CRTP was first introduced, under this name, by James Coplien in 1995, in his article in C++ Report. It is a particular form of a more general bounded polymorphism (Peter S. Canning et al., F-bounded polymorphism for object-oriented programming, Conference on Functional Programming Languages and Computer Architecture, 1989). While not a general replacement for virtual functions, it provides the C++ programmer with a similar tool that, under the right circumstances, offers several advantages.
What is wrong with a virtual function?
Before we can talk about a better alternative to a virtual function, we should consider why we would want to have an alternative at all. What is not to like about virtual functions?
The problem is the performance...