Consider the following demonstrative program.
#include <iostream>
template <class T1, class T2 = T1>
struct A
{
};
template <template <class> class T>
void f( const T<int> & )
{
std::cout << "f( const T<int> & )\n";
}
int main()
{
A<int> a;
f( a );
f<A>( a );
}
The compiler gcc HEAD 10.0.1 20200 compiles the program successfully and the program output is
f( const T<int> & )
f( const T<int> & )
The compiler clang HEAD 11.0.0 compiles neither the first call of the function f
nor the second call of the function f
. It issues an error message similar to that
prog.cc:25:5: error: no matching function for call to 'f'
f( a );
^
prog.cc:9:6: note: candidate template ignored: substitution failure: template template argument has different template parameters than its corresponding template template parameter
void f( const T<int> & )
^
1 error generated.
The compiler Visual C++ 2019 does not compile the first function call
f( a );
but compiles successfully the second function call
f<A>( a );
So a question arises which compiler behaves according to the C++ 17 (or maybe C++ 20) Standard?