TITLE: member function templates PROBLEM: patrick@zaphod.ruhr.de (Patrick Halke) Can somebody tell me why templates of member functions are not allowed ? For instance something like this: template class Foo { template T FooFunc(U u) { return (T)u; // :) } }; RESPONSE: clamage@Eng.Sun.COM (Steve Clamage), 3 Jun 95 When the template mechanism was being designed, there was concern about the effect of member templates. No one knew (since there were no implementations and no experience) what dangers there might be. It is easier to relax a restriction than to remove a language feature, so member templates were disallowed. After some experience, it is now known that member function templates for non-virtual functions do not cause problems. The language specification has been changed to allow them. It may be a while before compilers supporting this feature are widely available. Virtual functions cannot be member templates, since there would be no way to know at compile time how many different virtual functions would eventually be generated. (The implemenation isn't impossible, but would be very difficult on most systems, and increase program build times.)