Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Just use this->matrix = other.matrix;. std::swap would only be interesting to use if the class implemented a resource (See herehere).

Just use this->matrix = other.matrix;. std::swap would only be interesting to use if the class implemented a resource (See here).

Just use this->matrix = other.matrix;. std::swap would only be interesting to use if the class implemented a resource (See here).

added 22 characters in body
Source Link

Conclusion : this last solution is undeniably faster. Be careful, it is not everytime the case and only true here because of how operator+ can be implemented and because of the two assumptions, especially the second assumption thatone, i.e. default constructor >= copy constructor = move constructor (note that this conclusion would be also be true if default constructor = copy constructor = move constructor).

Conclusion : this last solution is undeniably faster. Be careful, it is not everytime the case and only true here because of how operator+ can be implemented and because of the second assumption that default constructor >= copy constructor = move constructor (note that this conclusion would be also be true if default constructor = copy constructor = move constructor).

Conclusion : this last solution is undeniably faster. Be careful, it is not everytime the case and only true here because of how operator+ can be implemented and because of the two assumptions, especially the second one, i.e. default constructor >= copy constructor = move constructor (note that this conclusion would also be true if default constructor = copy constructor = move constructor).

added 2 characters in body
Source Link

If the first argument is an lvalue, the pass-by-value (current) version of operator+ will call the copy constructor of mat4 to copy that object into lhs. Then when the function returns, it will call the move constructor of mat4 to move lhs into the object returnreturned by operator+. The reason why it is the move and not the copy constructor that is called is explained in the above given reference given above. Here is the interesting extract :

If the first argument is an lvalue, the pass-by-value (current) version of operator+ will call the copy constructor of mat4 to copy that object into lhs. Then when the function returns, it will call the move constructor of mat4 to move lhs into the object return by operator+. The reason why it is the move and not the copy constructor that is called is explained in the above given reference :

If the first argument is an lvalue, the pass-by-value (current) version of operator+ will call the copy constructor of mat4 to copy that object into lhs. Then when the function returns, it will call the move constructor of mat4 to move lhs into the object returned by operator+. The reason why it is the move and not the copy constructor that is called is explained in the reference given above. Here is the interesting extract :

added 12 characters in body
Source Link
Loading
Source Link
Loading