C++

Asked • 08/04/19

Advantages of using forward?

In perfect forwarding, `std::forward` is used to convert the named rvalue references `t1` and `t2` to unnamed rvalue references. What is the purpose of doing that? How would that affect the called function `inner` if we leave `t1` & `t2` as lvalues? template <typename T1, typename T2> void outer(T1&& t1, T2&& t2) { inner(std::forward<T1>(t1), std::forward<T2>(t2)); }

1 Expert Answer

By:

Dylan B. answered • 11/10/20

Tutor
New to Wyzant

Computer science Tutor, Associates degree, Real world experience

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.