#include <iostream>
void f(uint)
{
std::cout << "uint" << std::endl;
}
template<typename T>
void g(T x) {
f(x); // Lookup of f here finds f(int)
}
struct S {};
void f(S)
{
std::cout << "S" << std::endl;
}
void f(int)
{
std::cout << "int" << std::endl;
}
void f(double)
{
std::cout << "double" << std::endl;
}
int main() {
g(0);
g<double>(0.0);
g(S());
}
Z jakiego powodu w definicji funkcji g linkujemy sie do razu z f ktore jest dostepne f(uint) ? Czy nie powinnismy zaczekac na template instantiation i jak mamy juz wszystkie definicje to stworzyc odpowiednia funkcje g i zlinkowac z poprawna wersja ? Nie jestem w stanie zrozumiec dlaczego kompilator zachowuje sie w taki dziwny sposob :/