I wonder what's the right way of using a perfect forwarded functor? Here's two code snippet. Which one is the best, and if neither, what is the best form?
template<typename T, typename... Args>
void callMe(T&& func, Args&&... args) {
func(std::forward<Args>(args)...);
}
Or
template<typename T, typename... Args>
void callMe(T&& func, Args&&... args) {
std::forward<T>(func)(std::forward<Args>(args)...);
}
EDIT:
Will it impact overload resolution? If func
's operator()
has ref-qualifier for &&
or const &
, should I do the latter version and should I care about which overload I call?
Thanks!