template <typename T> void pass(T&& v) { reference(v); }
You use the forwarding link here pretty well, but the fact that there is now the name v , he considered lvalue reference to rvalue.
Simply put, all that has a name is an lvalue . That's why Perfect Forwarding is needed to get the full semantics, use std::forward
template <typename T> void pass(T&& v) { reference(std::forward<T>(v)); }
What std::forward<T> does is just do something like this
template <typename T> void pass(T&& v) { reference(static_cast<T&&>(v)); }
See this ;
source share