Hi all,
I'm trying to understand how the new (C++11) move constructor and move assignment works in classes.
Initially I thought I could test by simply having a 1 on 1 relation between a specific creation/ assignment of the class, which would call one of the 4 member functions:
- copy constructor
- move constructor
- copy assignment
- move assignment
The code/ test below works, but for example when I comment out just the "copy constructor", both nextPack(firstPack) and std::move(nextPack) are no longer allowed (deleted). I would think that the 2nd one (std::move(nextPack)) would be allowed, because I didn't explicitly call delete/ specify the move constructor. Other combinations (just specify 1 of the 4 in the class definition, leads to 2 of the 4 situations not being allowed, instead of 1).
I hope someone can shed some light on this.
// CLASS DEFINITION
CD3dShaderPack(const CD3dShaderPack& other) = delete; // copy constructor
// CD3dShaderPack(CD3dShaderPack&& other) = delete; // move constructor
// CD3dShaderPack& operator=(const CD3dShaderPack& other) = delete; // copy assignment
// CD3dShaderPack& operator=(CD3dShaderPack&& other) = delete; // move assignment
// TEST CASES
Crealysm::D3DRENDERER::CD3dShaderPack firstPack;
Crealysm::D3DRENDERER::CD3dShaderPack nextPack(firstPack); // copy constructor
nextPack = firstPack; // copy assignment
nextPack = std::move(firstPack); // move assignment
Crealysm::D3DRENDERER::CD3dShaderPack thirdPack(std::move(nextPack)); // move constructor