I have a template function, with several std::function type arguments, I want to default one of these arguments, such that the other programs calling it will not need to specify that input arguments. For example:
template<class T1, class T2>
dataStruct<T1, T2> foo(std::function<T2(T1, T1)> param_1,
std::function<T2(T1, T1)> param_2,
std::function<double(T1, T1)> param_3) {...}
I want to set param_3
to have a default value of 1.0
, so if I want to call this template function, I only need call it like this:
dataStruct<int, int> solution = foo(input_fun1, input_fun2);
such that I don't need to specify param_3
if its value is just default 1.0
. I know I can overload it with less parameters, but any way to skip this overload? like set default value in this template function directly? std::function<double(T1, T1)> param_3 = setToOne()
something like this?
Aucun commentaire:
Enregistrer un commentaire