dimanche 2 juin 2019

Why forwarding return value is needed

In the doc of std::forward, it gave the following example:

template<class T>
void wrapper(T&& arg)
{
    foo(forward<decltype(forward<T>(arg).get())>(forward<T>(arg).get()));
}

Why is forwarding of return value needed here? What's the cases where it is different to the following code:

template<class T>
void wrapper(T&& arg)
{
    foo(forward<T>(arg).get());
}

Aucun commentaire:

Enregistrer un commentaire