考慮以下函數將函數作爲參數。將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 */);