title: How to eliminate "divide by 0" error in template code
body: <p>I'm using a pair of integer template parameters to specify a ratio, since I can't use a double as a template parameter. The conversion into a double is protected against divide-by-zero with a ternary. This worked in an earlier version of the compiler, but Visual Studio 2013 gives an error:</p>
  
  <pre><code>error C2124: divide or mod by zero
  </code></pre>
  
  <p>Here's a simplified version of the code:</p>
  
  <pre><code>template&lt;int B1, int B2&gt;
  class MyClass
  {
      const double B = (B2 == 0) ? 0.0 : (double) B1 / (double) B2;
      // ...
  };
  
  MyClass&lt;0, 0&gt; myobj;
  </code></pre>
  
  <p>I really want <code>B</code> to be optimized out of expressions that use it when it's zero, so I need the single-line definition. I know I can just use template parameters <code>&lt;0, 1&gt;</code> to get around it, but I wonder if there's a way to just convince the compiler that my expression is safe?</p>