Minimal example:
class Task
{
public:
template<typename T, typename... Args>
static T* make(Args... args) {
return new T(args...);
}
}
template<typename A, typename B, typename C>
class MyTask : public Task
{
public:
MyTask(A a, B b, C c)
{
}
}
The make
factory method exists to get me out of having to supply all the template types when the templated, derived classes are instantiated.
I would like to be able to create an instance of MyTask as succinctly as possible, ie:
auto my_task = MyTask::make(a, b, c);
However, the compiler is insisting that it can't deduce T, and wants instead:
auto my_task = MyTask::make<MyTask<A, B, C>>(a, b, c);
It's not a huge deal-breaker, but the repetition seems unnecessary. Is there some way to get it the way I want?