Article View: comp.std.c++
Article #1721Re: Template Forward Declaration
From: Rick Hollinbeck
Date: Mon, 14 Aug 1995 03:03
Date: Mon, 14 Aug 1995 03:03
34 lines
1466 bytes
1466 bytes
Dirk Vermeersch (dirkv@netcom.com) wrote:
: I have a question about templates referencing other templates:
: Do template classes referenced by other templates have to be declared
: before being referenced? Or do they only need to be declared when the
: template is instantiated.
: For example :
: template <class T> class A {
: int f(B<T> &);
: };
: template <class T> class B {
: };
: /*
: is this valid under the standard?
: I know that Borland 4.02 and g++ 2.5.8 allow this, but is this allowed under
: the proposed standard?
: */
: Thanks,
: Dirk Vermeersch.
:
class template names behave just like class names and must be forward
declared.
Borland does not actually parse the template until it's instantiated,
which is why they don't catch this error.
If fact, you can even leave the trailing semicolon off a class template
and Borland C++ will not complain.
Technical Details
Message-ID:
<40lmnd$4ne@news-2.csn.net>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<dirkvDCExKr.E6K@netcom.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: rickh@csn.net (Rick Hollinbeck) Newsgroups: comp.std.c++ Subject: Re: Template Forward Declaration Date: 14 Aug 1995 03:03:16 GMT Organization: SuperNet Inc. (303)-296-8202 Denver Colorado Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <40lmnd$4ne@news-2.csn.net> References: <dirkvDCExKr.E6K@netcom.com> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: 199.117.27.22 X-Newsreader: TIN [version 1.2 PL2] Content-Length: 879 Originator: clamage@taumet