I have run into a situation that looks like this. I am using g++ on Windows 10.
#include <stdio.h>
template<typename _t>
struct test_thing {};
template<typename _t> void test_2(_t) { printf("A"); }
template<typename _t>
void test()
{
//test_2(_t{}); // prints: ABC
::test_2(_t{}); // prints: ABA <-- namespace op, searching different?
}
template<> void test_2(double) { printf("B"); }
template<typename _t> void test_2(test_thing<_t>) { printf("C"); }
int main()
{
test<int>();
test<double>();
test<test_thing<int>>();
return 0;
}
My question is why/how is the namespace op changing how the compiler is searching for the function to call. Doesn't the compiler find the most specialized template function that matches the args? If test_2(test_thing<_t>) is defined above test it finds it, but only with the ::, not below.