title: Simple C++11 constexpr factorial with ternary exceeds maximum template depth
body: <p>If I write a compile-time factorial function using specialisation, the following code can suffice, and will correctly provide 120 as the result of <code>fact1&lt;5&gt;()</code>:</p>
  
  <pre><code>template &lt;size_t N&gt;
  constexpr size_t fact1() { return N*fact1&lt;N-1&gt;(); }
  
  template &lt;&gt;
  constexpr size_t fact1&lt;0&gt;() { return 1; }
  </code></pre>
  
  <p>However, with a single function body and the ternary operator, as in the following code, G++ 4.7 and Clang++ 3.2 both exceed their maximum template instantiation depth. It appears that <code>1</code> is never returned from <code>fact2</code>. Why is it that this definition of <code>fact2&lt;5&gt;()</code> doesn't return 120?</p>
  
  <pre><code>template &lt;size_t N&gt;
  constexpr size_t fact2() { return N==0 ? 1 : N*fact2&lt;N-1&gt;(); }
  </code></pre>