Generic programming
In computer science, generics aretechnique that allows one valuetake different datatype (so-called polymorphism) asas certain contracts (so-called subtype)kept. The programming styleitcalled "generic programming".Among OOP languages, C++, Beta, Eiffel, Ada,later versionsJava provides generic facility. In C++, templates support genericspopularizednotiongenerics.
For example,C++ code,
templateT max (T x, T y) { if (x < y) return y; else return x;}
In this case,pseudo-datatype Tcalled "subtype". T can be anything that can be compared.
Uncommon, template metaprogramming iswaymaking algorithms evaluate when your codecompiled.
See also Partial evaluation
