Is using std::move() necessary?

Started by
11 comments, last by Zoomulator 11 years, 9 months ago
@Brother Bob: At the very moment of your answer, then it helped me very very much, because I didn't even know about move constructors and assignment operators. Thanks to you I really pushed forward my lib, because I was able to choose the philosophy for the class/function interfaces. And I am very grateful for your help. And now replacing std::move to " " in a few files is not a big problem smile.png
Advertisement
@Zoomulator: That is the case, making the long story short, the matrix looks like this:

template <class DATA_TYPE,INT_TYPE>
class Matrix{
private:
DATA_TYPE *Data;
INT_TYPE Rows,Cols;
public:
//all the stuff
};
Then it would indeed make sense to move it.

Just a side note about that though. If you're doing this to make use of move semantics and gain performance, you might actually not get much out of it. The indirection caused by the pointer may actually take more time due to cache misses than copying a small matrix, like 4x4, that's already present in the cache. The performance would be obvious in larger matrices of course. I recommend you do some tests, if this is for optimization.

This topic is closed to new replies.

Advertisement