   is using a function member class as a template parameter actually illegal?
  I have a trivially simple template function declaration: foo().I have another arbitrary function declaration: test().I define two trivially simple classes: CBar, CZug.CBar is defined globally.CZug is defined within test().I can call foo() perfectly using a CBar as the template parameter.However, using GCC I can't call foo() using a CZug as the parameter, even from within test where it is defined.template <typename tTYPE>void foo(tTYPE var) {}class CBar  {};void test()  {    CBar bar;    foo(bar); // OK.   class CZug {};   CZug zug;    foo(zug); // GCC ERROR: error: no matching function for call to 'foo(test(int, char**)::CZug&)  }Is this actually illegal? or is GCC wrong?I'm guessing it's illegal, but it can't fathom why.Thanks.details:c++: gcc (4.4)os: ubuntu (jaunty 64)   
  Local types can not be used as template parameters. For a nice explanation, see Vandevoorde/Josuttis, 8.3.2 Type Arguments.edit: Whoops, no explanation at that point. Don't have a copy handy to show you the right section in the book, but to explain the reason, types need external linkage, which local classes don't have. Note: External linkage is different from external visibility; private nested classes or classes in the anonymous namespace can very well be used as template parameters!Sidenote: In the upcoming standard, local classes derive linkage from the enclosing function, hence you will be able to use local classes as template parameters if the function is non-static.   ;  Thanks - that was fast.8.3.2.1 states that local classes and enumerations can't be involved in template type arguments, but it doesn't say why. But the why's only a curiosity anyway.   ;Quote:Original post by yacwroy8.3.2.1 states that local classes and enumerations can't be involved in template type arguments, but it doesn't say why. But the why's only a curiosity anyway.I edited my post ;);  Cool, didn't know that.For anyone else following this:http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htmis the proposal for the change.linked from gcc's c++0x status page:http://gcc.gnu.org/projects/cxx0x.htmlI wish they gave a timeline tho.Now I'll have to litter my code with // <FIX> (C++0x:N2402) Put class inside function.   