During my presentation of "Universal References in C++11" at C++ and Beyond 2012, I gave the advice to apply
std::moveto rvalue reference parameters and
std::forwardto universal reference parameters. In this post, I'll follow the convention I introduced in that talk of using RRef for "rvalue reference" and URef for "universal reference."
Shortly after I gave the advice mentioned above, an attendee asked what would happen if
std::forwardwere applied to an RRef instead of
std::move. The question took me by surprise. I was so accustomed to the RRef-implies-
std::forwardconvention, I had not thought through the implications of other possibilities. The answer I offered was that I wasn't sure what would happen, but I didn't really care, because even if using
std::forwardwith an RRef would work, it would be unidiomatic and hence potentially confusing to readers of the code.
The question has since been repeated on stackoverflow, and I've also received it from attendees of other recent presentations I've given. It's apparently one of those obvious questions I simply hadn't considered. It's time I did.