[comp.lang.c++] Templates

markr@and.cs.liv.ac.uk (06/17/91)

I started a C++ project that needed many generic classes (sets, lists etc.) and
decided to use templates.  Until we get a compiler that supports them I am
using the cpp from ti.

I notice recently there has been a lot of talk of templates on this group.  I
don't know much about the situation, and would like to ask:-

*	are templates part of a standard for C++, or just a proposal?

*	do any compilers support them yet?

*	when will the AT&T compiler support them?  2.3, 3.0, 16.8 or what?

*	when they are supported, how efficient will they be in terms of
	avoiding code duplication?  Will it be necessary to define a general
	base class and use templates for type-specific derived classes?
	(eg. template <class T> class Set<T> : public GenericSet {...})

*	how does use of templates with the ti macro package differ from the
	standard/proposal for the language?

--
Mark Rivers
CompSci Liverpool Uni UK

steve@taumet.com (Stephen Clamage) (06/19/91)

markr@and.cs.liv.ac.uk writes:

>I notice recently there has been a lot of talk of templates on this group.  I
>don't know much about the situation, and would like to ask:-

>*	are templates part of a standard for C++, or just a proposal?

There is no standard for C++ yet.  E&S (the ARM) describes templates,
and is the model the ANSI C++ committee is using.  The final standard
for C++ will include templates, and will look much like what is in E&S.
Templates in their final form may or may not be identical to what is
now in E&S.

>*	do any compilers support them yet?

No released commercial compilers that I know of.

>*	when they are supported, how efficient will they be in terms of
>	avoiding code duplication?  Will it be necessary to define a general
>	base class and use templates for type-specific derived classes?
>	(eg. template <class T> class Set<T> : public GenericSet {...})

Read E&S for a description of how they work.

>*	how does use of templates with the ti macro package differ from the
>	standard/proposal for the language?

The TI implementation is not a full template implementation.  The whole
job requires more than can be done by a preprocessor.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com

jimad@microsoft.UUCP (Jim ADCOCK) (06/19/91)

In article <1991Jun16.173916.143@and.cs.liv.ac.uk| markr@and.cs.liv.ac.uk writes:
|I notice recently there has been a lot of talk of templates on this group.  I
|don't know much about the situation, and would like to ask:-
|
|*	are templates part of a standard for C++, or just a proposal?

Last I had heard, the ANSI C++ committee had voted templates "in"
the language spec -- and then immediately turned around and started 
arguing about the exact syntax that should be used for templates.
Turns out I guess that using '<' and '>' as template brackets leads
to some pretty ambiguous parsing [probably not surprising considering
that '<' and '>' have radically different meanings throughout the 
rest of the language]

Still, to date, I think the description in Ellis and Stroustrup's
ARM -- "The Annotated C++ Reference Manual" -- is the best reference
on templates.  [ Check out the updated Lippman when it comes out :-]

sarima@tdatirv.UUCP (Stanley Friesen) (06/19/91)

In article <1991Jun16.173916.143@and.cs.liv.ac.uk> markr@and.cs.liv.ac.uk writes:
>
>I notice recently there has been a lot of talk of templates on this group.  I
>don't know much about the situation, and would like to ask:-
>
>*	are templates part of a standard for C++, or just a proposal?

They are part of the proposed standard.  (The committee is firm on this).

>*	do any compilers support them yet?

I am not sure, the latest version of cfront from ATT has added one of
exception handling or templates (but I do not remember which).
Also, I have heard that at least one specialty C++ compiler has an
implementation.

>*	when they are supported, how efficient will they be in terms of
>	avoiding code duplication?  Will it be necessary to define a general
>	base class and use templates for type-specific derived classes?
>	(eg. template <class T> class Set<T> : public GenericSet {...})

This will be implementation dependent.  As I understand it most currently
proposed implementations rather tend towards duplicate code.
-- 
---------------
uunet!tdatirv!sarima				(Stanley Friesen)

wlp@calmasd.Prime.COM (Walter L. Peterson, Jr.) (06/20/91)

In article <49@tdatirv.UUCP> sarima@tdatirv.UUCP (Stanley Friesen) writes:
>In article <1991Jun16.173916.143@and.cs.liv.ac.uk> markr@and.cs.liv.ac.uk writes:
>>*	do any compilers support them yet?
>
>I am not sure, the latest version of cfront from ATT has added one of
>exception handling or templates (but I do not remember which).
>Also, I have heard that at least one specialty C++ compiler has an
>implementation.
>


The C++ compiler that comes with the ObjectStore OODBS from Object
Design has implemented templates.  I have not yet used this myself,
but AT&T did license this implementation of templates from
Object Design for its own use, so that is something of an endorsement.

ObjectStore is made and sold by:

	Object Design
	One New England Executive Park
	Burlington, MA 01803
	Phone: (617) 270-9797
	FAX:   (617) 270-3509
	

	
-- 
             "Exploring the Consensual Hallucination of Cyberspace"
                           Walter L. Peterson, Jr.
Internet : wlp@calmasd.Prime.COM | CompuServe : 70441,3144 | GEnie: WPETERSON5
                       "Insert generic disclaimer here"

ianhogg@cs.umn.edu (Ian J. Hogg) (06/21/91)

In article <773@taumet.com> steve@taumet.com (Stephen Clamage) writes:
>markr@and.cs.liv.ac.uk writes:
>
>There is no standard for C++ yet.  E&S (the ARM) describes templates,
>and is the model the ANSI C++ committee is using.  The final standard
>for C++ will include templates, and will look much like what is in E&S.
>Templates in their final form may or may not be identical to what is
>now in E&S.
>
>>*	do any compilers support them yet?
>
>No released commercial compilers that I know of.
>

  The version of Cfront you get with ObjectStore has templates.  AT&T has
licensed the code from ObjectDesign.


-- 
===============================================================================
Ian Hogg						ianhogg@cs.umn.edu
                                                        (612) 225-1401