title: ambiguous template instantiation error with gcc
body: <p>For the code below I get an ambiguous template instantiation error with gcc.
  However, using Clang or Visual Studio the Code compiles fine. 
  A full working example of the code can be found here:
  <a href="http://coliru.stacked-crooked.com/a/60ef9d73ce95e6f9" rel="nofollow noreferrer">http://coliru.stacked-crooked.com/a/60ef9d73ce95e6f9</a></p>
  
  <p>I have a class template that is build from an aggegate type </p>
  
  <pre><code>template&lt;template&lt;typename...&gt; typename AggregateType, typename ...&gt;
  struct MyClass;
  </code></pre>
  
  <p>The aggregate type is composed from a list of base classes, for example </p>
  
  <pre><code>template&lt;typename ... Bases&gt;
  struct Aggregate : Bases...
  { };
  </code></pre>
  
  <p>I have defined two specialzations of MyClass. The first specialization is the common case and reads</p>
  
  <pre><code>// specialization for two argument list for the
  // aggregate type
  template&lt;template&lt;typename...&gt; typename AggregateType,
        typename Base,
        typename ... Bases1,
        typename ... Bases2&gt;
  struct MyClass&lt;
        AggregateType,
        AggregateType&lt;Bases1...&gt;,
        AggregateType&lt;Base, Bases2...&gt;&gt;
  {
        void func()
        {
         std::cout &lt;&lt; "not specialized\n";
        }
  };
  </code></pre>
  
  <p>A second specialization handels the case when the the second base list has only 1 argument</p>
  
  <pre><code>// specialization for the second argument list with length 1
  template&lt;template&lt;typename...&gt; typename AggregateType,
       typename Base,
       typename ... Bases1&gt;
  struct MyClass&lt;
      AggregateType,
      AggregateType&lt;Bases1...&gt;,
      AggregateType&lt;Base&gt;&gt;
  {
    void func()
    {
      std::cout &lt;&lt; "specialized\n";
    }
  };
  </code></pre>
  
  <p>Using MyClass with a second argument list of length 1, I expected the compiler to choose the second specialization of MyClass, since it is the more specilized template</p>
  
  <pre><code>class Foo {};
  class Bar {};
  
  int main()
  {
    // this should give the not specialized class
    using NotSpecialized = MyClass&lt;Aggregate, Aggregate&lt;Foo, Bar&gt;, Aggregate&lt;Foo, Bar&gt;&gt;;
    NotSpecialized ns;
    ns.func();
  
    // this should give the specialized class
    using Specialized = MyClass&lt;Aggregate, Aggregate&lt;Foo, Bar&gt;, Aggregate&lt;Foo&gt;&gt;;
    Specialized s;
    s.func();
  }
  </code></pre>
  
  <p>While the code works fine with Clang, gcc gives an ambiguous template instantiation error. How can I circumvent this error and still use gcc?
  If I remove the AggregateType template argument, the code also works with gcc, see <a href="http://coliru.stacked-crooked.com/a/c1f6edd5fab7df4d" rel="nofollow noreferrer">http://coliru.stacked-crooked.com/a/c1f6edd5fab7df4d</a></p>