I have a template builder/factory class that makes objects of type Foo, where the make() method is a template method, like so:
template<typename T1>
class FooMaker
{
template<typename T2>
Foo make(...) { ... }
};
The idea here is that T1 is bound to the builder since it's the same for all make() invocations, while T2 (which is always a function name) is usually different for each make() call.
I'm calling make() many times to create different types of objects, and the combination of a template class and a template functions means I have to use the template disambiguator before every call to make:
template <typename MAKER_T>
void make_some_foos()
{
auto maker = FooMaker<MAKER_T>(...);
Foo foo1 = maker.template make<Type1>(...);
Foo foo2 = maker.template make<Type2>(...);
// etc...
}
I'd like to needing the template keyword on each line that constructs a Foo above. In general I have many calls to make() on each FooMaker object, so a small amount of additional code when creating the factory would be fine.
Evidently I could do this using a macro which hides the template detail, but is there a good non-macro solution1?
1 I could move T1 and T2 to the same level - by making them both class template arguments, or both function template arguments, but the former would need a distinct maker for every new type T2 and the latter means redundantly specifying the same T1 in every make call.