#include <iostream>
#include <functional>
template<typename T>
struct id { typedef T type; };
template<typename T>
void f(T b, typename id<T>::type* a){}
int main() {
f(0, 0);
}
vs2013:好的!
g++4.8.2:compile error,such is the info:
main.cpp: In function 'int main()':
main.cpp:10:10: error: no matching function for call to 'f(int, int)'
f(0,0);
^
main.cpp:10:10: note: candidate is:
main.cpp:7:6: note: template<class T> void f(T, typename id<T>::type*)
void f(T b, typename id<T>::type* a){}
^
main.cpp:7:6: note: template argument deduction/substitution failed:
main.cpp:10:10: note: mismatched types 'typename id<T>::type*' and 'int'
f(0,0);
^