Consider a simple example:
template <class T>
struct foo {
template <template <class> class TT>
foo(TT<T>&&) {}
foo(foo<T>&&){}
foo() {}
};
int main() {
foo f1(foo<int>{}); //case 1.
foo<int> f2(foo<int>{}); //case 2.
}
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?
Error message:
prog.cc:10:14: error: ambiguous deduction for template arguments of 'foo'
foo f1(foo<int>{}); //case 1.
^
prog.cc:4:5: note: candidate function [with T = int, TT = foo]
foo(TT<T>&&) {}
^
prog.cc:5:5: note: candidate function [with T = int]
foo(foo<T>&&){}
^
1 error generated.