Why can't std::as_const(T &&v) move-return its argument?
问题 Reading Why does as_const forbid rvalue arguments? I understand that we can't convert a rvalue-ref into an lvalue-ref, of course. But why not move the rvalue-ref into a value and return that, i.e. ? template<typename T> const T as_const(T&& val) { return std::move(val); } This ought to work nicely with COW containers as well, as the returned value is const and iterators from it will not cause it to detach. Maybe some godbolt-ing will answer this though, but I can't think of a given scenario