考虑以下函数将函数作为参数。将std :: forward作为默认参数传递?
template <class Function = std::plus<int> >
void apply(Function&& f = Function());
这里std::plus<int>
是应用的默认功能。 std::plus<int>
是一个功能对象,一切正常。
现在,我想通过std::forward<int>
作为默认参数。 std::forward<int>
不是函数对象,这是一个函数指针。怎么做 ?
template <class Function = /* SOMETHING */ >
void apply(Function&& f = /* SOMETHING */);