unexpected output with templates and non-templates functions
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/12174493/template-func-and-non-template-func-call-order">Template func and non template func call order</a>  </p>
</blockquote>



<p>Why does this code code print</p>

<pre><code>::foo(int)
::foo&lt;T&gt;(T)
</code></pre>

<p> </p>

<pre><code>template &lt;typename T&gt;
void foo(T)
{
   std::cout &lt;&lt; "::foo&lt;T&gt;(T) \n";
}

template &lt;typename T&gt;
void bar(T baz)
{
   foo(baz);
}

void foo(int)
{
   std::cout &lt;&lt; "::foo(int) \n";
}

int main()
{
   foo(0);
   bar(0); 
}
</code></pre>

<p>while this</p>

<pre><code>void foo(int)
{
   std::cout &lt;&lt; "::foo(int) \n";
}

template &lt;typename T&gt;
void foo(T)
{
   std::cout &lt;&lt; "::foo&lt;T&gt;(T) \n";
}

template &lt;typename T&gt;
void bar(T baz)
{
   foo(baz);
}

int main()
{
   foo(0);
   bar(0); 
}
</code></pre>

<p>prints</p>

<pre><code>::foo(int)
::foo(int)
</code></pre>

<p>as expected.</p>
