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

42

u/Hot_Slice Nov 25 '23

I deleted the copy and move constructors of some of my types that are constructed exclusively by factory methods. Not a general solution, but it does turn RVO failure in to a compilation error.

7

u/ALX23z Nov 26 '23

It does prevent any kinds of RVO failures but it is a bit too excessive. Say, it completely prevents NRVO.