title: SFINAE : Derived class hide base class function depend on T
body: <p>There are 2 SFINAE snippets that I coded.<br>
  They do exactly the same thing.<br>
  However, the first one works, while the second doesn't.<br>
   Why?  (The second is more similar to my real program.)</p>
  
  <p>This code works ( <a href="http://coliru.stacked-crooked.com/a/50e07af54708f076" rel="nofollow noreferrer">http://coliru.stacked-crooked.com/a/50e07af54708f076</a> )</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include  &lt;type_traits&gt;
  enum EN{ EN1,EN2 };
  template&lt;EN T1&gt; class B{
      public: template&lt;EN enLocal=T1&gt; typename     
        std::enable_if&lt;enLocal==EN1,void&gt;::type test(){  std::cout&lt;&lt;"1"&lt;&lt;std::endl;}  
      public: template&lt;EN enLocal=T1&gt; typename    
        std::enable_if&lt;enLocal==EN2,void&gt;::type test(){  std::cout&lt;&lt;"2"&lt;&lt;std::endl; }
  };
  
  int main(){
      B&lt;EN1&gt; b;
      b.test(); 
  }
  </code></pre>
  
  <p>But this code is uncompilable  (<a href="http://coliru.stacked-crooked.com/a/28b6afd443b36c7e" rel="nofollow noreferrer">http://coliru.stacked-crooked.com/a/28b6afd443b36c7e</a>) :-</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include  &lt;type_traits&gt;
  enum EN{ EN1,EN2 };
  class Base{
      public: void test(){
          std::cout&lt;&lt;"1"&lt;&lt;std::endl;
      };
  };
  template&lt;EN T1&gt; class B : public Base{
      public: template&lt;EN enLocal=T1&gt; 
        std::enable_if_t&lt; enLocal==EN2,void &gt; test(){
          std::cout&lt;&lt;"2"&lt;&lt;std::endl;
      }
  };
  int main(){
      B&lt;EN1&gt; bEn1; bEn1.test(); //should print 1
      //B&lt;EN2&gt; bEn2; bEn2.test(); //print 2
  }
  </code></pre>
  
  <p>I am very new to SFINAE and still learning it via <a href="https://stackoverflow.com/a/50562202/">https://stackoverflow.com/a/50562202/</a>. </p>