Is it well-defined to cast xvalues to lvalues for passing to functions?
问题 Recently I've discovered that sometimes being able to turn rvalues temporarily into lvalues can be useful for me. I've been using the following tool: #include <type_traits> template <typename T> inline constexpr std::remove_reference_t<T> &lvalue(T &&r) noexcept { return static_cast<std::remove_reference_t<T> &>(r); } It's useful when you have to use functions that require lvalues as arguments, but you don't have any interest in what those particular values get changed into. For when you are