C++ destructor functor with type erasing