What are the cases when std::forward
is not needed? It is used to wrap inner function argument which is templated-rvalue (that is, it can be lvalue or named-rvalue). Like in:
template<class T>
void outer(T&& t) {
inner(std::forward<T>(t));
}
I am guessing one case is when inner function parameters are passed by value. Are there other cases? I've got this question when I was writing std::begin(std::forward<Ct>(ct))
where Ct is templated-rvalue-ref.
EDIT about possible duplicate
If I remember correctly, this is 3rd attempt to close this 4yr old question as duplicate by some newbie who don't understand the question.
"Advantages of using forward?" and "When not to use std::forward with r-values?" are very different questions. First is introduction into r-values for beginners and second is discussion of perfect forwarding for advanced C++ user. I am author of meta-template library and lambda library, who don't need verbose description of basics. Information in answer is very different from other question.