我有一个类似以下的对象,我正在尝试实现一个移动构造函数,以便您可以插入std::vector<Mesh>
.
struct Mesh
{
std::vector<Vector3> vPoint;
bool Valid;
Mesh(Mesh&& other)
{
vPoint = std::move(other.vPoint);
Valid = std::move(other.Valid);
}
};
这是正确的方法吗?如果是这样,在 std::move 对其进行操作之后 other.Valid 的值是多少?
编辑:
另外,如果我有这个对象的实例,我是否需要在以下场景中使用 std::move?
std::vector<Mesh> DoSomething()
{
Mesh mesh; //Imagine vPoint is filled here to
std::vector<Mesh> meshes;
meshes.push_back(std::move(mesh)); // Here is my question, std::move? or just pass mesh here?
return meshes;
}