We have already seen an example where type erasure was used very successfully—the std::shared_ptr shared pointer. On the other hand, the standard library authors did not use this technique when they implemented std::unique_ptr, and not because it is any more difficult (our simple smartptr is, in fact, a lot closer to std::unique_ptr than std::shared_ptr, since it does not do any reference counting).
Then there was the unsuccessful attempt to type-erase the sort and related functions, which ended in a complex mess that was cleaned up once and for all by letting the compiler deduce the right types, instead of erasing them. We could do with some guidelines for when to consider type erasure. There are two types of issues to keep in mind—design considerations and performance considerations.