SFINAE works with deduction but fails with substitution : <p>Consider the following MCVE</p>

<pre><code>struct A {};

template&lt;class T&gt;
void test(T, T) {
}

template&lt;class T&gt;
class Wrapper {
    using type = typename T::type;
};

template&lt;class T&gt;
void test(Wrapper&lt;T&gt;, Wrapper&lt;T&gt;) {
}

int main() {
    A a, b;
    test(a, b);     // works
    test&lt;A&gt;(a, b);  // doesn't work
    return 0;
}
</code></pre>

<p>Here <code>test(a, b);</code> works and <code>test&lt;A&gt;(a, b);</code> fails with:</p>

<pre><code>&lt;source&gt;:11:30: error: no type named 'type' in 'A'
    using type = typename T::type;
                 ~~~~~~~~~~~~^~~~
&lt;source&gt;:23:13: note: in instantiation of template class 'Wrap&lt;A&gt;' requested here
    test&lt;A&gt;(a, b);  // doesn't work
            ^
&lt;source&gt;:23:5: note: while substituting deduced template arguments into function template 'test' [with T = A]
    test&lt;A&gt;(a, b);  // doesn't work
</code></pre>

<p><a href="https://gcc.godbolt.org/z/XLrOSX" rel="noreferrer">LIVE DEMO</a></p>

<p><strong>Question:</strong> Why is that? Shouldn't SFINAE work during <em>substitution</em>? Yet here it seems to work during <em>deduction</em> only.</p>
