In the comments, I mentioned the following approach:
template<typename T> class Factory { public: template<typename ...Args> auto construct(Args && ...args) { return T(std::forward<Args>(args)...); } };
So your first public class method will be something like this:
template<typename T> auto getFactory() { return Factory<T>(); }
So:
auto factory=object.getFactory<someClass>(); // Then later: factory.construct(std::string("Foo"), bar()); // And so on...
Instead of construct() you can use operator() too, so the second part of this will be simple:
factory(std::string("Foo"), bar());
As I said, this is not erasing styles. You cannot use type erasure here.
Having given this a few thoughts, the reason why type erasure cannot be used here is because this instance of type erasure needs to be “self-preserving” or atomic, and you need to do to break atomic erase into two parts or two classes in your case.
This will not work. An erase type, by definition, takes a type and erases it. As soon as your first type of function erases the class method template parameter, what you end up with is an opaque, type-erased object. What is erased is no longer available to the outside world. But you still haven't typed the erasable parameters of your constructor, which happens elsewhere.
You can type-erase the template class and constructor parameters together. You cannot type the template type and constructor parameters separately and then somehow erase the result again.
A simple factory-based approach, like the one I outlined, will be closest to results similar to type erasing if both halves of your desired erase styles appear in the same area, so you can actually avoid erasing styles and instead rely on styles bloated compiler.