Named Rvalues Are Lvalues
#include <cstdio>
#include <string>
#include <utility>
void sink(const std::string&) { std::puts("lvalue"); }
void sink(std::string&&) { std::puts("rvalue"); }
template <class T>
void relay(T&& x) { sink(x); }
int main() {
std::string s = "hello";
relay(s); // (1)
relay(std::string("world")); // (2)
}
What does this print?
Sign in to answer questions and track your progress
Sign In