c++ - 使用指针向量移动构造函数
问题描述
我应该如何为带有指针的向量执行移动构造函数?例如:
我在 A 类中有这个作为字段 -vector<A*> AList;
在函数(A &&otherA)
中(这是移动构造函数),我应该这样写:
AList(std::move(other.AList))
还是以其他方式?
解决方案
Yes, you can do it like that.
Or, if you don't need the move assignment operator to do anything else, just leave it out and the compiler will do this for you.
This goes for moving any member vector.
推荐阅读
- python - 对象检测图像文件夹读取返回
返回 NULL 而不设置错误 - mysql - Doctrine DQL - 防止笛卡尔连接
- markdown - 如何在 m2r2 中使用“m2r_parse_relative_links”?
- javascript - 检查 discord bot 命令的参数是否与命令配置指定的格式匹配
- python - add_roles 的 Discord.py 问题
- r - 得到“不能对不存在的列进行子集化。” 当 dplyr 确实存在该列时
- vim - 我们能否在评论部分转义类型、代码等,以便拼写检查不会将它们视为拼写错误
- java - 配置 Swagger-ui 路径
- python - 不可能做到“从硒导入网络驱动程序”
- angular - 加载资源失败:服务器响应状态为 404 (Not Found)-lab-logo.png