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

What goes wrong if you replace std::forward<T>(x) with std::move(x) in this forwarding constructor?

template <class T> Wrapper(T&& x) : value(/* forward or move? */ x) {} std::string s = "hi"; Wrapper<std::string> w(s); // pass an lvalue