Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC++perfect forwarding std::forwardSingle-choice MCQ

Why does the second member function correctly preserve value categories while the first does not, even though both 'forward' their argument?

template <typename T> struct Box { T value; template <typename U> void bad(U&& u) { sink(std::forward<T>(u)); } template <typename U> void good(U&& u) { sink(std::forward<U>(u)); } };