title: C++ operator overloading doesn't respect math requirements
body: <p>I have to write a math library for internal use. I started to look at different implementation from open source libs and I found some weird things on operator overloading - they don't respect mathematical/logical requirements</p>
  
  <p>Example 1: Irrlight Matrix (<a href="http://irrlicht.sourceforge.net/docu/matrix4_8h_source.html" rel="nofollow">http://irrlicht.sourceforge.net/docu/matrix4_8h_source.html</a>)</p>
  
  <ul>
  <li><code>operator*</code> is overloaded for non-commutative operation</li>
  <li><code>operator+/-/+=/-=</code> are overloaded, but they don't have any logical meaning in 3D engine context(result is a matrix that doesn't represent any valid transformation).</li>
  </ul>
  
  <p>Example 2: GLM Matrix (<a href="http://glm.g-truc.net/" rel="nofollow">http://glm.g-truc.net/</a>)</p>
  
  <ul>
  <li><code>operator++/--</code> are overloaded, but they don't have any logical meaning in 3D engine context(result is a matrix that doesn't represent any valid transformation).</li>
  <li><code>operator+=/-=</code> are overloaded, but they don't have any logical meaning in 3D engine context(result is a matrix that doesn't represent any valid transformation).</li>
  </ul>
  
  <p>Similar examples can be found on different types in almost all libraries I've checked. 
  I've read in Elements of Programming by Alexander Stepanov that one shouldn't change operators meaning nor implement them when they don't make sense, but I see many example where these guidelines are not respected.</p>
  
  <p>Is this a good practice? If yes can you please give me arguments. If no, why everybody does this?</p>
  
  <p>EDIT:</p>
  
  <p>I'll try to get a better example: </p>
  
  <pre><code>template &lt;typename U&gt;
  GLM_FUNC_DECL tvec4&lt;T&gt; &amp; operator*=(tvec4&lt;U&gt; const &amp; v);
  </code></pre>
  
  <p>with this implementation</p>
  
  <pre><code>template &lt;typename T&gt;
  template &lt;typename U&gt; 
  GLM_FUNC_QUALIFIER tvec4&lt;T&gt; &amp; tvec4&lt;T&gt;::operator*=
  (
      tvec4&lt;U&gt; const &amp; v
  )
  {
      this-&gt;x *= T(v.x);
      this-&gt;y *= T(v.y);
      this-&gt;z *= T(v.z);
      this-&gt;w *= T(v.w);
      return *this;
  }
  </code></pre>
  
  <p>Can you please explain what is the meaning of this in the context of mathematical vectors(not colors or points or... something else that can be represented as 4 elements array)? </p>