TITLE: templates as wrappers PROBLEM: Larry Stein [...] I know that I can solve the problem using a template class, but is the compiler going to implement this efficiently? It would be a shame if it had to generate new template code for each different pointer type I instantiated my class with. RESPONSE: vandevod@cs.rpi.edu (David Vandevoorde) You can help your compiler a great deal. E.g.: struct ptr_list_core { // ... Type independent part, perhaps using void* }; template struct ptr_list: ptr_list_core { // ... Add or replace member functions that depend on T* }; [...] [ The above problem is referring to code such as template class X { // X interface stuff }; // X implementation stuff where the type T is always instantiated as a different kind of pointer. The compiler will generate implementations of X for each type of pointer, which the original poster was complaining about. The second respondent notes that you can frequently write X with out templates in terms of void*, then use a template to derive from X. This template class will simply perform the casting to and from void* and the instantiated pointer type. -adc ] RESPONSE: kanze@lts.sel.alcatel.de (James Kanze), 5 Oct 95 It helps with another problem, too. Using this technique, it often becomes feasible to make all of the functions in the template class inline. This is practically the only way to write a template class today which can actually be used by more than one compiler. [ Apparently there are still poor implementations of templates by some compilers. -adc ]