title: std::enable_if using its internal type and without using it
body: <p>Why does it print "B"</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template&lt;typename T, typename U = void&gt;
  struct Test
  { static void apply() { std::cout &lt;&lt; "A" &lt;&lt; std::endl; } };
  
  template&lt;typename T&gt;
  struct Test&lt;T, typename std::enable_if&lt;true&gt;::type&gt;
  { static void apply() { std::cout &lt;&lt; "B" &lt;&lt; std::endl; } };
  
  int main()
  {
      Test&lt;int&gt;::apply();
  }
  </code></pre>
  
  <p>but this one "A"?:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template&lt;typename T, typename U = void&gt;
  struct Test
  { static void apply() { std::cout &lt;&lt; "A" &lt;&lt; std::endl; } };
  
  template&lt;typename T&gt;
  struct Test&lt;T, std::enable_if&lt;true&gt;&gt;
  { static void apply() { std::cout &lt;&lt; "B" &lt;&lt; std::endl; } };
  
  int main()
  {
      Test&lt;int&gt;::apply();
  }
  </code></pre>
  
  <p>The only difference between them is that, in the first one, I'm using <code>typename std::enable_it&lt;true&gt;::type</code> as <code>U</code> (e.g, <code>void</code>), but in the second one, I'm directly using <code>std::enable_if&lt;true&gt;</code> as <code>U</code>, which is also a well defined type and with no more meaning as <code>void</code>.</p>