r/cpp • • Jul 04 '18

Be Mindful with Compiler-Generated Move Constructors

https://ibob.github.io/blog/2018/07/03/compiler-generated-move/
86 Upvotes

46 comments sorted by

View all comments

Show parent comment

2

u/miki151 gamedev Jul 04 '18

It seems dumb, and if the language started from scratch, it would be dumb to design like this. Having unknown amount of code broken wasn't an option though.

Wouldn't that code be broken by C++11 anyway? The default move constructor wouldn't know it should allocate anything.

3

u/00kyle00 Jul 04 '18

Default move-ctor wouldn't be generated for those types. The issue is that there would be no way to write a non-default move-ctor for them - affected stdlib types would have to be made non-movable.

And that would be completely arbitrary list. Im not sure whether what we have right now is better though. Im sure it was considered by the committee.