Can constructor template cause ambiguity in the c++17 parameter deduction of class template : <p>Consider a simple example:</p>

<pre><code>template &lt;class T&gt;
struct foo {
    template &lt;template &lt;class&gt; class TT&gt;
    foo(TT&lt;T&gt;&amp;&amp;) {}
    foo(foo&lt;T&gt;&amp;&amp;){}
    foo() {}
};

int main() {
    foo      f1(foo&lt;int&gt;{}); //case 1.
    foo&lt;int&gt; f2(foo&lt;int&gt;{}); //case 2.
}
</code></pre>

<p>Case 1. causes ambiguity in the template argument deduction of foo class in clang but not in gcc. I thought that template functions (here - constructor) have lower priority in overload resolution. Is it not the case here?</p>

<p>Error message:</p>

<pre><code>prog.cc:10:14: error: ambiguous deduction for template arguments of 'foo'
    foo      f1(foo&lt;int&gt;{}); //case 1.
             ^
prog.cc:4:5: note: candidate function [with T = int, TT = foo]
    foo(TT&lt;T&gt;&amp;&amp;) {}
    ^
prog.cc:5:5: note: candidate function [with T = int]
    foo(foo&lt;T&gt;&amp;&amp;){}
    ^
1 error generated.
</code></pre>

<p><a href="https://wandbox.org/permlink/EpN6M1DB26MDozE8" rel="noreferrer">[clang demo]</a> <a href="https://wandbox.org/permlink/3cj3562mRnavT3Im" rel="noreferrer">[gcc demo]</a></p>
