Topic: explicit template instantiation
Author: 917312523 <helmut.zeisel@aon.at>
Date: 1997/01/29 Raw View
Stroustrup's Appendix to the ARM,
ANSI/ISO Resolutions, r14.9 says:
"Duplicate explicit instantiation is technically an error"
1) Is this still valid?
2) If class A<T> uses class Other<T> in its implementation,
is class Other<T> automatically instantiated when
class A<T> is instantiated explicitely?
a) If yes:
What happens when a different class B<T> that
also needs Other<T> is explicitely instantiated?
Class Other<T> is then duplicately instantiated;
is this an error?
b) if no:
Do I have to know all the implementation details
of class A<T> to be able to explicitely
instantiate explicitely all the needed templates?
By the way, is there a good reference how to instantiation
mechanism (automatically and explicit) is standardized?
Newsfeed unreliable, please answer also via E-mail
Helmut Zeisel <helmut.zeisel@aon.at>
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: John Lilley <jlilley@empathy.com>
Date: 1997/01/30 Raw View
917312523 wrote:
> 2) If class A<T> uses class Other<T> in its implementation,
> is class Other<T> automatically instantiated when
> class A<T> is instantiated explicitely?
Yes, but the instantiation of Other<T> would be classified as an
implicit instantiation (even if Other<T> is a base class).
> What happens when a different class B<T> that
> also needs Other<T> is explicitely instantiated?
No problem, Other<T> is implicitly instantiated in both cases.
> By the way, is there a good reference how to instantiation
> mechanism (automatic and explicit) is standardized?
There is no standardization of the *mechanism*. If you read the (draft)
standard carefully, you can get a feel for what plausible implementation
mechanisms people had in mind when the standard was cast.
As far as I know, there is no easily-digested source of information
about the mechanics of template instantiation. The "SIGS C++ Report"
has frequent articles about STL and templates, which help. Other then
that, get the latest (dec96) draft.
I have some ideas for a plausible implementation that I've been working
on -- drop me a line if you're interested in the ugly details.
john lilley
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]