Article View: comp.std.c++
Article #3752Re: Template instantiation
From: Nathan Myers, http://www.cantrip...
Date: Thu, 21 Mar 1996 02:48
Date: Thu, 21 Mar 1996 02:48
35 lines
2224 bytes
2224 bytes
John E. Potter wrote:
>
> I have only found one compiler which accepts the following. The others
> attempt to instantiate class N prior to completing class L. As I read
> DWP-14.3 [temp.inst], class N<int> should not be instantiated in the
> following code. It would be instantiated when some class L<int> function
> used an N<int>.
>
> template <class T> class N;
> template <class T> class L { N<T>* ptr; };
> template <class T> class N { L<T> next; };
> int main () { L<int> l; }
>
> Do I have one correct compiler that accepts it, several correct compilers
> which reject it, or (I hope not) all correct compilers because it is not
> specified?
You have one (at least semi-) correct compiler, and several broken ones.
> If the latter, is there any standard way to make this portable? I can
> change ptr to a void* and reinterpret_castrate everything, but that is
> not very pleasing.
You could change the member to a void* and provide an (inline) access
function that does the cast, in only one place. Better to use
non-broken compilers, of course.
Nathan Myers
ncm@cantrip.org http://www.cantrip.org/
---
[ 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 ]
Technical Details
Message-ID:
<314FA6C4.6816C82B@cantrip.org>Path:
arc1-ca.pugleaf.net!cs.mu.OZ.AU!bounce-backReferences:
<4if8u9$6lf@jake.esu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!cs.mu.OZ.AU!bounce-back From: "Nathan Myers, http://www.cantrip.org/" <ncm@cantrip.org> Newsgroups: comp.std.c++ Subject: Re: Template instantiation Date: 21 Mar 96 02:48:58 GMT Organization: The Cantrip Cooperative Approved: fjh@cs.mu.oz.au Message-ID: <314FA6C4.6816C82B@cantrip.org> References: <4if8u9$6lf@jake.esu.edu> NNTP-Posting-Host: mundook.cs.mu.oz.au X-Original-Date: Tue, 19 Mar 1996 22:33:40 -0800 X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.13 i386) X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMVDDuOEDnX0m9pzZAQHa9wF/QyVyoYiMNIO6P1k8K4K43agyAmCFglAd xLCCFPfFzpu4WhC0AkK+Oo91jIXOFfiO =EVTe Originator: fjh@mundook.cs.mu.OZ.AU