Author: Dann Corbit
Date: 14:49:24 12/11/01
Go up one level in this thread
On December 11, 2001 at 17:25:26, Roy Eassa wrote: [snip] >I was under the impression that templates were a new programming construct with >C++ (i.e., they did not exist in any language before they were introduced into >C++). Am I incorrect? The idea of Generic programming clearly predates templates. For instance, in Ada, we had generic packages long before templates were invented. However, I broadly prefer the template implementation. Take a gander at the STL complex template sometime, and see the incredible power of the template idea. I can create a template that uses a big number class as easily as a float, double, or long double complex type. Here are some templates I wrote which are freely available for any use: A Kahan adder (see http://docs.sun.com/htmlcoll/coll.648.2/iso-8859-1/NUMCOMPGD/ncg_goldberg.html under "Theorem 8 Kahan Summation Formula"): ftp://cap.connx.com/pub/tournament_software/Kahan.Hpp Here is a statistics template that uses Kahan adders: ftp://cap.connx.com/pub/tournament_software/STATS.HPP Here is a template for Skiplists: ftp://cap.connx.com/pub/Public_CAP_Results/Brainy/SKIPLIST.HPP The nice thing about templates is not writing them {which can be a bit of a pain} but rather in *using* them. For instance, if I want to make a dictionary from my skiplist, I just declare one with string as the type and bam - instant dictionary. Any class that has a greater than operator can be used by simply declaring it and we immediately have a typesafe ADT container. I used it (for instance) to create a very compressed version of EPD data that can be used for inquiry as to analyzed positions. It can be just as useful for any sort of thing that needs O(log(n)) search time. I'm really enamored with templates.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.