I have an object similar to the following, and I'm trying to implement a move constructor, so you can have an insert for std::vector<Mesh> .
struct Mesh { std::vector<Vector3> vPoint; bool Valid; Mesh(Mesh&& other) { vPoint = std::move(other.vPoint); Valid = std::move(other.Valid); } };
Is it correct? And if so, what is the value of other.Valid after std :: move works on it?
Edit:
Also, if I have an instance of this object, do I need to use std :: move in the following script?
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; }
c ++ c ++ 11 move-semantics
Ntccobalt
source share