Barton-Nackman |
Barton-Nackman is a programming trick in C plus plus invented by John Barton and Lee Nackman [1]. Originally, it provided a way to overloading function Generic_programming when the C++ language did not support the feature. Barton and Nackman took advantage of a process called friend name injection , in which the C++ Compiler used the type parameters of a Class_(object-oriented_programming) template to instantiate nontemplate friend functions of that class and then compiled them under normal rules of function overloading [2,3].
Today the Barton-Nackman trick has become synonymous with curiously recurring templates (a term due to Coplien [4], but which Barton and Nackman popularized), in which a base class template is instantiated with a derived class type as its template parameter. This is useful for Partial_evaluation of polymorphism_(computer_science) behavior. For example, a base class instance can be made to call a derived class member function without using the virtual function table, since the Compiler can resolve the function call during compilation. For sample code, see [http://osl.iu.edu/~tveldhui/papers/techniques/techniques01.html#l14 Techniques for Scientific C++, Section 1.3.3].
= See Also =
Inheritance_in_object-oriented_programming
Comparison_of_generics_to_templates
Template_metaprogramming
= References =
[1]
[2]
[3]
[4]
[5]|
|