Ho un oggetto simile al seguente e sto cercando di implementare un costruttore di spostamento per così puoi avere un inserto per std::vector<Mesh>
.Sposta Constructor, sposta vettore tra due oggetti usando std :: move?
struct Mesh
{
std::vector<Vector3> vPoint;
bool Valid;
Mesh(Mesh&& other)
{
vPoint = std::move(other.vPoint);
Valid = std::move(other.Valid);
}
};
È il modo corretto? E se sì qual è il valore di other.Valid dopo std :: move opera su di esso?
Edit:
Anche se ho un'istanza di questo oggetto ho bisogno di usare std :: mossa nel seguente scenario?
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;
}
Perché vuoi 'spostare' un' bool'? – us2012
@ us2012 Sono solo curioso di sapere cosa succede con 'std :: move' o altri tipi interi. Copia il valore su 'this.Valid' e poi imposta' other.Valid' sul valore predefinito di bool (aka false)? –
NtscCobalt