Yes, you should use std::move() in the move constructor, just like you. However, your move constructor exactly duplicates the default value. If your class does not define any of them:
- copy constructor Assignment operator
- Assignment operator
- destructor
then a default move constructor will be created for you, which will do exactly what you did. You better abandon the definition and rely on the standard version.
Even if your class defines some of the above, you can ask the compiler to generate a default move constructor:
class Mesh { public: Mesh(Mesh &&) = default;
Thus, you do not need to define it, and it will work even if you add other participants later (without risk forgetting to add them to the manual move constructor).
Unfortunately, none of the above applies to Visual Studio 2015 or earlier, which cannot generate default move constructors and does not support = default for move operations. Therefore, if you are targeting VS <= 2015, you must specify a manual move constructor & mdash, just like you.
Angew source share