Article View: comp.std.c++
Article #2363Re: Template Instantiation
From: Michael Rice
Date: Mon, 30 Oct 1995 18:05
Date: Mon, 30 Oct 1995 18:05
47 lines
2200 bytes
2200 bytes
> I believe it is implicit in the semantic descriptions throughout the DWP.
> For functions (member or not), they should only be instantiated if they
> are called. The only exception are virtual functions: they can be
> instantiated if the class to which they belong is instantiated.
>
> Classes and member classes should be instantiated only if their size
> or at least part of their layout is needed. If only their name is needed,
> no instantiation should occur.
>
What about the use of a typedef name from the class. No size or layout
is needed. Example:
struct incomplete;
template <class T>
struct allocator {
public :
typedef T* pointer;
incomplete i;
};
template <class T>
struct vector {
allocator<T>::pointer start;
vector();
};
main()
{
vector<int> v;
return 0;
}
Then this should be well-formed. While specializing vector<int> we have
to determine the member start's type. We don't need to specialize
allocator<int> to do that. So we can use allocator<int>::pointer, and
allocator<anything>::pointer without ever specializing the class. Is that
the intent? Is that desirable?
--
Mike Rice Absoft Corporation
mpr@absoft.com (810) 853-0050
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<47345t$ouk@engnews1.eng.sun.com>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: "Michael Rice" <mpr@absoft.com> Newsgroups: comp.std.c++ Subject: Re: Template Instantiation Date: 30 Oct 1995 18:05:49 GMT Organization: ? Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <47345t$ouk@engnews1.eng.sun.com> NNTP-Posting-Host: taumet.eng.sun.com Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII"; conversions="7bit, 7bit" Content-Transfer-Encoding: 7bit In-Reply-To: <VANDEVOD.95Oct29114646@avs.cs.rpi.edu> from "David Vandevoorde" at Oct 30, 95 02:49:11 am X-Mailer: ELM [version 2.4 PL22] X-Lines: 43 Content-Length: 1281 Originator: clamage@taumet