I am coding functions like the well known tuple_apply, which take a rvalue reference of a Function as parameter. During my researches on the web, I came across the two following calls:
template <
typename Func,
/* stuff */
>
void myfunction(Func && func, /* stuff */)
{
std::forward<Func>(func)(/* stuff */); // use of std::forward before call
func(/* stuff */); // direct call
}
Is this call to std::forward really usefull ? If so why ?
Thanks for your enlightenment!
Aucun commentaire:
Enregistrer un commentaire