title: Check whether multiplication will overflow
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/199333/best-way-to-detect-integer-overflow-in-c-c">Best way to detect integer overflow in C/C++</a>  </p>
  </blockquote>
  
  
  
  <p>Currently I use the following function:</p>
  
  <pre><code>template&lt;typename T, typename U&gt;
  bool is_mul_safe(T x, U y) {
      return (ld(x * 1.) + ld(y * 1.)) - (sizeof(decltype(x * y)) &lt;&lt; 3) &lt;= 0;
  }
  </code></pre>
  
  <p>Is there a standard library function which provides the same functionality?</p>