Topic: function templates
Author: schmidt@liege.ics.uci.edu (Douglas C. Schmidt)
Date: 4 Mar 1994 15:51:32 -0800 Raw View
Hi,
I understand that the latest working draft of the ISO/ANSI C++
standard now includes more flexible support for function templates.
In particular, if there is a function:
----------------------------------------
template <class C>
int compare (const String& s1,
const String& s2)
{
//...
if (!C::eq (s1[i], s2[i]))
//...
}
----------------------------------------
and a class:
----------------------------------------
class CMP
{
public:
static int eq (char a, char b);
};
----------------------------------------
and two String objects:
----------------------------------------
String s1, s2;
----------------------------------------
then we could invoke this template using some sort of notation such
as:
----------------------------------------
1. compare<CMP> (s1, s2);
2. compare (s1, s2, CMP);
----------------------------------------
However, I'm not sure which version (1 or 2) of the syntax is the
correct one. Could someone please let me know!
Thanks,
Doug
--
Douglas C. Schmidt
Department of Information and Computer Science
University of California, Irvine
Irvine, CA 92717. Work #: (714) 856-4105; FAX #: (714) 856-4056