Explicitly defaulted move constructor

醉酒当歌 提交于 2019-11-29 06:58:16

The motivation for that rule is that if the default copy constructor doesn't work for your class, then chances are the default move constructor won't work either (rule of 5, or whatever we're up to in C++11). So yes, you can explicitly default it, on your honor as a programmer that it'll work.

In your example code you could instead remove the copy constructor, since it does the same as the default.

Yes, you can always explicitly invoke the default generation for functions that can be automatically generated with = default. That's what the syntax is for.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!