首页 > 解决方案 > 使用指针向量移动构造函数

问题描述

我应该如何为带有指针的向量执行移动构造函数?例如:
我在 A 类中有这个作为字段 -vector<A*> AList; 在函数(A &&otherA)中(这是移动构造函数),我应该这样写:
AList(std::move(other.AList))还是以其他方式?

标签: c++pointersvectormove-constructor

解决方案


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.


推荐阅读