So I quite do not understand how compiler chooses function overloads. I've thought that I understand until this code:
#include <iostream>
using namespace std;
template<class T>
struct base_type:
public T
{
};
template<class T>
void check(T (&)[sizeof(base_type<T>)/sizeof(base_type<T>)]) {std::cout << "yeah";}
template<class T>
void check(T) {std::cout << "nah";}
union U{};
struct S{};
int main()
{
U u[1];
S s[1];
check(u); // compile error
check(s);
return 0;
}
Why compiler did not choose 2d overload of check(T)
when it has failed to check size of the array reference in fist overload?