std::forward_list <T> copy_list(const std::forward_list<T>& in)
{
auto out = in;
out.reverse();
return out;
}
auto out = in;
The lifetime of a temporary object may be extended by binding to a const lvalue reference or to an rvalue reference (since C++11), see reference initialization for details.