move semantics and cv::Mat

There is no need to do this. cv::Mat's copy constructor doesn't actually copy the data. It basically makes a reference and all objects share the same data.

cv::Mat::Mat(const Mat & m)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters

m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied by these constructors. Instead, the header pointing to m data or its sub-array is constructed and associated with it. The reference counter, if any, is incremented. So, when you modify the matrix formed using such a constructor, you also modify the corresponding elements of m . If you want to have an independent copy of the sub-array, use Mat::clone()


As of 4.x OpenCV provides Mat (Mat &&m) and Mat & operator= (Mat &&m).

If you are working on a version prior to 4.x, I'd suggest to take a look at the cv::Mat move constructor and move assignment operator implementations defined in modules/core/include/opencv2/core/mat.inl.hpp, as it's a little more complicated that just copying the .data member.