Overloaded function template disambiguation with `std::enable_if` and non-deduced context : <p>Consider the following code:</p>

<pre><code>template &lt;typename T&gt;
struct dependent_type
{
    using type = T;
};

template &lt;typename T&gt;
auto foo(T) -&gt; std::enable_if_t&lt;std::is_same&lt;T, int&gt;{}&gt;
{
    std::cout &lt;&lt; "a\n"; 
}

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

<ul>
<li><p>The first overload of <code>foo</code> can deduce <code>T</code> from its invocation.</p></li>
<li><p>The second overload of <code>foo</code> is a <a href="http://en.cppreference.com/w/cpp/language/template_argument_deduction#Non-deduced_contexts" rel="noreferrer"><em>non-deduced context</em></a>.</p></li>
</ul>

<p></p>

<pre><code>int main()
{    
    foo&lt;int&gt;( 1 );      // prints "b"
    foo&lt;double&gt;( 1.0 ); // prints "b"
    foo( 1 );           // prints "a"
}
</code></pre>

<p><strong>Why does <code>foo&lt;int&gt;( 1 )</code> print "b" and not "a"?</strong></p>

<p><a href="http://melpon.org/wandbox/permlink/rzRrewtogo1iCjAv" rel="noreferrer"><strong>wandbox example</strong></a></p>
