title: calculating factorial using template meta-programming
body: <p>I do not understand how this piece of code <a href="http://en.wikipedia.org/wiki/Template_metaprogramming" rel="noreferrer">(from Wikipedia)</a> works:</p>
  
  <pre><code>template &lt;int N&gt;
  struct Factorial 
  {
      enum { value = N * Factorial&lt;N - 1&gt;::value };
  };
  
  template &lt;&gt;
  struct Factorial&lt;0&gt; 
  {
      enum { value = 1 };
  };
  
  // Factorial&lt;4&gt;::value == 24
  // Factorial&lt;0&gt;::value == 1
  void foo()
  {
      int x = Factorial&lt;4&gt;::value; // == 24
      int y = Factorial&lt;0&gt;::value; // == 1
  }
  </code></pre>
  
  <ul>
  <li>What is this weird template that
  takes <code>&lt;int N&gt;</code>?</li>
  <li>What is this second
  weird template <code>&lt;&gt;</code>?</li>
  <li>What are the
  <code>enum</code>erations for?</li>
  <li>What is the advantage
  of using this rather than normal
  runtime factorial calculation?      </li>
  <li>How often do you people use this? I have been using C++ for a while now, but never used this before. How big a part of C++ was I missing out on?</li>
  </ul>
  
  <p>Thanks!</p>