steve@taumet.com (Stephen Clamage) (02/15/91)
dfoster@jarthur.Claremont.EDU (Derek R. Foster) writes: >While reading this newsgroup recently, I have run across several >references to "templates", which I am presuming (perhaps incorrectly) >are the long-awaited addition of generic types to C++. That's what they are. >I have only heard passing references to templates, however. Have they >been "officially" added to C++? Not yet. There are some experimental partial implementations. >Is there an agreed-upon syntax? Not yet, but see Ellis & Stroustrup, "The Annotated C++ Reference Manual". There is some discussion in the ANSI C++ committee (X3J16) concerning the adequacy of the syntax. The specified syntax has some known ambiguities. >Could someone give some simple examples which would show this syntax? See E&S. -- Steve Clamage, TauMetric Corp, steve@taumet.com
steven@uicadd.csl.uiuc.edu (Steven Parkes) (02/15/91)
I'm curious as to where discusion of templates is occuring ....
For example:
In considering templates for current code, the following situation came
up:
template <class Key, class Value>
class Mapping {
static const int defaultTableSize;
static const int defaultMaximumDensity;
static const float defaultGrowthRate;
}
To initialize these static variables, a template of the form
template <class Key, class Value>
const int Mapping<Key,Value>::defaultTableSize = 11;
is needed -- however, E&S states that ``The declaration in a
template-declaration must declare or define a function or a class.''
It seems pretty clear that this type of assignment should be allowed.
steven parkes ---------------------------------------
University of Illinois Coordinated Science Laboratory
steven@pacific.csl.uiuc.edu -------------------------
benson@odi.com (Benson I. Margulies) (02/16/91)
In article <603@taumet.com> steve@taumet.com (Stephen Clamage) writes: >dfoster@jarthur.Claremont.EDU (Derek R. Foster) writes: > >>While reading this newsgroup recently, I have run across several >>references to "templates", which I am presuming (perhaps incorrectly) >>are the long-awaited addition of generic types to C++. > >That's what they are. > >>I have only heard passing references to templates, however. Have they >>been "officially" added to C++? > >Not yet. There are some experimental partial implementations. They've been approved by the ANSI committe, and announced as part of cfront 3.0. They're available today in the C++ included with ObjectStore. -- Benson I. Margulies
jimad@microsoft.UUCP (Jim ADCOCK) (02/23/91)
In article <603@taumet.com> steve@taumet.com (Stephen Clamage) writes: |dfoster@jarthur.Claremont.EDU (Derek R. Foster) writes: |>I have only heard passing references to templates, however. Have they |>been "officially" added to C++? | |Not yet. There are some experimental partial implementations. My understanding is that templates were voted "in" to the language in the November ansification meeting. Mind you, its not all over till the fat lady sings....but, I believe vendors will start adding templates to their implementations in anticipation of the inclusion of templates in the final release of the ansi spec. -- There was little disagreement over the need nor form of templates. |>Is there an agreed-upon syntax? | |No
wmm@world.std.com (William M Miller) (02/23/91)
There have been several partially-incorrect responses to questions about the actual status of templates in the ANSI standard draft, so I'd like to set the record straight. First, templates were accepted by the X3J16 committee at the July meeting; chapter 14 of E&S, minus the annotations and commentary, was inserted verbatim into the working draft. That means that they are as much an "official" part of the language as inheritance or references -- that is, unless the committee takes explicit action to change or remove them, they will stand as described. At the November meeting, some objections were raised regarding the syntax of templates, particularly with regard to the use of < and > as the delimiters of the parameter list because of the ambiguities introduced. Two proposals were advanced to fix the problems; one was a rather complete rewrite of the syntax, the other simply replaced < and > with (< and >). No decision was reached on any revision; the issue will be discussed again at the March meeting. Regarding the implementation status of templates, it is public knowledge that AT&T has acquired the implementation of templates done by Object Design for inclusion in a future version of cfront. That implementation was, of course, done using the description of templates reflected in E&S. Other compiler vendors are adding templates to their products, as well. I don't know shipping time frames, however. -- William M. Miller, Glockenspiel, Ltd. Vice chair, X3J16 wmm@world.std.com