title: Why are these templates ambiguous?
body: <p>The book <a href="https://rads.stackoverflow.com/amzn/click/com/0201734842" rel="noreferrer" rel="nofollow noreferrer">C++ Templates : The Complete Guide</a> has an example on page 275 that I'm having trouble wrapping my head around.</p>
  
  <p>Quoting excerpts from the book...</p>
  
  <pre><code>template &lt;typename T&gt;
  class Promotion&lt;T,T&gt; {
    public:
      typdef T ResultT;
  };
  
  template&lt;typename T1, typename T2&gt;
  class Promotion&lt;Array&lt;T1&gt;, Array&lt;T2&gt; &gt; {
    public:
      typedef Array&lt;typename Promotion&lt;T1,T2&gt;::ResultT&gt; ResultT;
  };
  
  template&lt;typename T&gt;
  class Promotion&lt;Array&lt;T&gt;, Array&lt;T&gt; &gt; {
    public:
      typedef Array&lt;typename Promotion&lt;T,T&gt;::ResultT&gt; ResultT;
  };
  </code></pre>
  
  <blockquote>
    <p>Unfortunately, the partial specialization <code>Promotion&lt;Array&lt;T1&gt;, Array&lt;T2&gt; &gt;</code> is 
    neither more nor less specialized than the partial specialization 
    <code>Promotion&lt;T,T&gt;</code>. To avoid template selection ambiguity, the last partial 
    specialization was added. It is more specialized than either of the previous 
    two partial specializations.</p>
  </blockquote>
  
  <p>Why are the first two templates ambiguous, and why does the last template solve the ambiguity issue? When I try to apply the rules I either can't figure out how it comes up with an ambiguity, or if I think I have a way for it to happen I don't know why the last template solves the problem.</p>