Given the following program
#include <iostream>
template<class T> struct id { using type = T; };
template<class T1, class T2>
int func(T1, T2) { return 0; }
template<class T1, class T2>
int func(typename id<T1>::type, typename id<T2>::type) { return 1; }
int main()
{
std::cout << func<int, int>(0, 0) << std::endl;
}
GCC and Clang both prints 1 for this program. Is this program guaranteed to print 1 by the standard?
I tried finding the answer here but couldn't decipher it. It looks like the function templates might be equivalent and therefore breaks ODR but I'm not sure.
Does changing the second function template to
template<class T>
using id_type = typename id<T>::type;
template<class T1, class T2>
int func(id_type<T1>, id_type<T2>) { return 1; }
make a difference?