Comment by spot5010
Maybe a compiler error that a const object cannot be “moved”?
That would force the programmer to remove the std::move, making it clear that its a copy.
Maybe a compiler error that a const object cannot be “moved”?
That would force the programmer to remove the std::move, making it clear that its a copy.
There are cases where you would not want to reject such code, though. For example, if std::move() is called inside a template function where the type in some instantiations resolves to const T, and the intent is indeed for the value to be copied. If move may in some cases cause a compiler error, then you would need to write specializations that don't call it.