to_check.cpp: In function ‘int main()’:
to_check.cpp:16: error: type of ‘& foo<int>’ is unknown
to_check.cpp:16: error: invalid type in declaration before ‘;’ token
to_check.cpp:17: error: type of ‘& bar<int>’ is unknown
to_check.cpp:17: error: invalid type in declaration before ‘;’ token
The compiler should be able to determine the type of an instance of a pointer to function/method template. Right?
typeof is not, to the best of my knowledge generally supported in C++. I think it's going to be in the next version, or maybe it's just been added in the most recent. Maybe someone can confirm one way or the other. That said I've used an ancient version of g++ (2.95.3) and it will happily compile it.
You say you compiled it with gcc 4.2.3, is that gcc or g++ you used? If it was gcc it should be g++. gcc is the C compiler, g++ is the C++ compiler
Some times we need to have a specialized templates within a specific scope, in which case, it would be used within that scope.
But you are trying to use it from main, which is out of struct's scope.
If you want to have such generic template within the scope, you better try to use it within the struct's scope and redesign the code.