I was looking at the std::function implementation and its call operator()
template<typename Ret, typename... ArgTypes>
Ret function< Ret (ArgTypes...)>::operator()(ArgTypes...args) const
{
// some stuff
return invoker(functor, std::forward<ArgTypes>(args)...);
}
I was particularly wondering, why it uses std::forward here? Does this anything have to do with perfect forwarding? Because perfect forwarding could only be done if operator() is a template with a variadic template declaration template<typename... Args> (which it is not). What is the intention of using std::forward here? I am confused :-)?
Aucun commentaire:
Enregistrer un commentaire