Why does this function return an lvalue reference given rvalue arguments?
问题 The following definition of a min function template <typename T, typename U> constexpr auto min(T&& t, U&& u) -> decltype(t < u ? t : u) { return t < u ? t : u; } has a problem: it seems that it's perfectly legal to write min(10, 20) = 0; This has been tested with Clang 3.5 and g++ 4.9. The solution is straightforward, just use std::forward to restore the "rvalue-ness" of the arguments, i.e. modify the body and the decltype to say t < u ? std::forward<T>(t) : std::forward<U>(u) However, I'm