title: How Does std::enable_if work?
body: <p>I just asked this question: <a href="https://stackoverflow.com/questions/25251380/stdnumeric-limits-as-a-condition">std::numeric_limits as a Condition</a></p>
  
  <p>I understand the usage where <code>std::enable_if</code> will define the return type of a method conditionally causing the method to fail to compile.</p>
  
  <pre><code>template&lt;typename T&gt;
  typename std::enable_if&lt;std::numeric_limits&lt;T&gt;::is_integer, void&gt;::type foo(const T &amp;bar) { isInt(bar); }
  </code></pre>
  
  <p>What I don't understand is the second argument and the seemingly meaningless assignment to <code>std::enable_if</code> when it's declared as part of the template statement, as in <a href="https://stackoverflow.com/users/1381108/rapptz">Rapptz</a> <a href="https://stackoverflow.com/questions/25251380/stdnumeric-limits-as-a-condition/25251506#25251506">answer</a>.</p>
  
  <pre><code>template&lt;typename T, typename std::enable_if&lt;std::is_integral&lt;T&gt;::value, int&gt;::type = 0&gt;
  void foo(const T&amp; bar) { isInt(); }
  </code></pre>