title: Can a compiler perform global optimization on similar template classe member function?
body: <p>I’m creating a new container. One of its template parameters is its initial capacity. As a result, creating instances with different initial capacities will result in the compiler generating the same code for each templated class.</p>
  
  <pre><code>MyVector&lt;3&gt; firstVector;
  MyVector&lt;4&gt; secondVector;
  ...
  if (firstVector.empty() &amp;&amp; secondVector.empty())
  {
     ...
  }
  </code></pre>
  
  <p>This snippet would cause the compiler to generate <code>empty()</code> for both classes. Can a compiler eliminate this redudancy?</p>