g++-4.6はどうやってこうなった?
この間リナカフェでも話したお話なんですが
#include <iostream> using namespace std; template<class T> struct id{ typedef T type; }; template<class T> void f(T t){ cout << "ue" << endl; } template<class T> void f(id<T>::type t){ cout << "shita" << endl; } int main() { f<int>(0); return 0; }
i686-apple-darwin10-g++-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5494) i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664) g++-mp-4.4 (GCC) 4.4.4 test1.cpp: In function ‘int main()’: test1.cpp:28: error: call of overloaded ‘f(const int&)’ is ambiguous test1.cpp:10: note: candidates are: void f(T) [with T = int] test1.cpp:15: note: void f(typename id<T>::type) [with T = int]
一方
g++ (GCC) 4.6.0 20100703 (experimental) ./a.out second
コンパイルが通る。
でこれは4.6に成った際に何かが入ってしまったとかそういうアレなのかなぁって言う。GHCで言う所の、IncoherentInstances的な・・・?