The following program, which uses a local class object as an argument to a templated function, does not compile using gcc 4.1.1:
The error is:Code:template<class T> void f(T) {} int main() { class A {} a; f(a); }
test.cxx: In function ‘int main()’:
test.cxx:6: error: no matching function for call to ‘f(main()::A&)’
However, if I make the class nonlocal, then it does:
I'm new to C++, and suspect that using the local class is somehow illegal. Is this true, or is the compiler broken?Code:template<class T> void f(T) {} class A {}; int main() { A a; f(a); }