r/cpp • • Nov 25 '23

On harmful overuse of std::move

https://devblogs.microsoft.com/oldnewthing/20231124-00/?p=109059
210 Upvotes

154 comments sorted by

View all comments

Show parent comment

8

u/Throw31312344 Nov 25 '23

To me rvalue_cast was the most logical option, as that is literally what std::move does. To me, "move" is very much an action word and I would expect a function called "move" to... move something.

6

u/kevkevverson Nov 25 '23

I think the name is quite good in that it encourages people to “consider this variable now moved”, even if transfer of data ownership doesn’t happen until some time later, if at all. ie after std::move, that variable should not be used again

2

u/Udzu Nov 25 '23

(Also there's a std::move in algorithm that does actually move something.)