As shown in the 'possible implementation' of std::apply
we see that the standard library function std::invoke
is used to invoke the callable object F
.
Is it needed in this situation? if so, for what reason?
What are the benefits of writing:
template<typename F, typename ... Args>
decltype(auto) func(F &&f, Args &&... args){
return std::invoke(std::forward<F>(f), std::forward<Args>(args)...);
}
over:
template<typename F, typename ... Args>
decltype(auto) func(F &&f, Args &&... args){
return std::forward<F>(f)(std::forward<Args>(args)...);
}
?