title: Ambiguous call not avoided by SFINAE
body: <p>Compiling this code :</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  
  template &lt;int N&gt;
  struct TestClass {
      template &lt;int N2, typename std::enable_if&lt;N2 == N, int&gt;::type = 0&gt;
      void doAction() { std::cout &lt;&lt; "TestClass::doAction&lt;" &lt;&lt; N &lt;&lt; "&gt;();\n"; }
  };
  
  struct HostClass : public TestClass&lt;1&gt;, public TestClass&lt;2&gt; {
  };
  
  
  int main(int argc, const char * argv[]) {
      HostClass hostClass;
  
      hostClass.doAction&lt;1&gt;();
      hostClass.doAction&lt;2&gt;();
  
      return 0;
  }
  </code></pre>
  
  <p>leads to an ambiguous call error because <code>doAction</code> is both in <code>TestClass&lt;1&gt;</code> and <code>TestClass&lt;2&gt;</code> parent classes.</p>
  
  <blockquote>
    <p>main.cpp:33:15: Member 'doAction' found in multiple base classes of different types</p>
  </blockquote>
  
  <p>But <code>std::enable_if</code> would not disable this ambiguity ?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I think the real reason to this ambiguity is the same than in this question :</p>
  
  <p><a href="https://stackoverflow.com/questions/5368862/why-do-multiple-inherited-functions-with-same-name-but-different-signatures-not">Why do multiple-inherited functions with same name but different signatures not get treated as overloaded functions?</a></p>
  
  <p>The ambiguity can be resolved as shown in the answer with the <code>using</code> keyword :</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  
  template &lt;int N&gt;
  struct TestClass {
      template &lt;int N2, typename std::enable_if&lt;N2 == N, int&gt;::type = 0&gt;
      void doAction() { std::cout &lt;&lt; "TestClass::doAction&lt;" &lt;&lt; N &lt;&lt; "&gt;();\n"; }
  };
  
  struct HostClass : public TestClass&lt;1&gt;, public TestClass&lt;2&gt; {
      using TestClass&lt;1&gt;::doAction;
      using TestClass&lt;2&gt;::doAction;
  };
  
  int main(int argc, const char * argv[]) {
      HostClass hostClass;
  
      hostClass.doAction&lt;1&gt;();    // OK, compile
      hostClass.doAction&lt;2&gt;();    // OK, compile
      //hostClass.doAction&lt;3&gt;();  // OK, doesn't compile : "candidate template ignored: disabled by 'enable_if' [with N2 = 3]"
  
      return 0;
  }
  </code></pre>
  
  <p>I don't know if it was what @skypjack answer meant but I let it anyway for its alternative method.</p>