Using type erasure to achieve polymorphism in C++.