The compiler can only deduce template arguments for function templates, not class templates. That leaves you with a few choices: the most obvious (but often least convenient) is to specify the template parameters when you instantiate your compose2
.
Marginally less obvious, but often more convenient is to create a function template that deduces the parameters, and creates a compose2
object using the deduced types:
template<class BinaryFunction, class UnaryFunction1, class UnaryFunction2>
compose2<BinaryFunction, UnaryFunction1, UnaryFunction2>
make_compose2(BinaryFunction binFunc, UnaryFunction1 unFunc1, UnaryFunction2 unFunc2) {
return compose2_t<BinaryFunction, UnaryFunction2, UnaryFunction2>
(binFunc, unFunc1, unFunc2);
}
Then the client code will use make_compose2
instead of compose2
, and the template parameters can/will be deduced from the types of the passed parameters.