Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC++move semantics and rvalue refsSingle-choice MCQ

Given perfect-forwarding overload resolution, which constructor is selected for the marked line?

struct W { W(const std::string&) { /* (1) */ } W(std::string&&) { /* (2) */ } }; std::string s = "hi"; W a(s); // <-- this line W b(std::move(s)); W c("literal");