| ▲ | spot5010 9 hours ago | |||||||
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. | ||||||||
| ▲ | fluoridation 7 hours ago | parent | next [-] | |||||||
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. | ||||||||
| ||||||||
| ▲ | ziml77 8 hours ago | parent | prev | next [-] | |||||||
It's weird that they made a mistake of allowing this after having so many years to learn from their mistake about copies already being non-obvious (by that I mean that references and copies look identical at the call sites) | ||||||||
| ▲ | lang4d 7 hours ago | parent | prev [-] | |||||||
clang-tidy has a check for this case | ||||||||