Article View: comp.std.c++
Article #1895Re: Equivalence of A and A<>
From: Biomechanics Inc.
Date: Sun, 03 Sep 1995 09:11
Date: Sun, 03 Sep 1995 09:11
35 lines
1786 bytes
1786 bytes
In article <9524503.22797@mulga.cs.mu.OZ.AU> you write:
>gcato@st6000.sct.edu (Vaughn Cato) wrote:
>>template <class T = int> class A;
>>
>>void f() {
>> A<> *p1; // The legal way to default the argument
>> A *p2; // Syntax error
>>}
>
> template <int i = 42> struct A { A(int = 0) {} };
> foo(*new A<0>(0));
> // should that be parsed as `foo((*new A) < 0) > 0)'??
I see how use with the new operator could cause an ambiguity. If the form
without <> was treated as as a secondary syntax I don't believe it would be
a problem though:
template <int i = 42> class A;
class B;
new A<0>(0); /* Interpreted as usual. */
new A(0); /* Interpreted as new A<0>(0) since it would be a syntax
error otherwise */
new B<0>(0); /* Interpreted as ((new B)<0)>0 as usual */
new B(0); /* Interpreted as usual. */
Of course, this is messy. It is basically the same as how the declaration/
constructor call ambiguity is resolved.
Until Later,
Vaughn Cato (gcato@st6000.sct.edu)
---
[ 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:
<199509022122.AA05995@crl9.crl.com>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<199508241251.IAA03008@gold.interlog.com> <MATT.95Aug24145052@physics2.Berkeley.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 03 Sep 95 09:11:58 GMT Approved: fjh@cs.mu.oz.au X-Original-Date: Sat, 2 Sep 1995 14:22:09 -0700 From: "Biomechanics Inc." <biomech@crl.com> Message-ID: <199509022122.AA05995@crl9.crl.com> Newsgroups: comp.std.c++ In-Reply-To: <9524503.22797@mulga.cs.mu.OZ.AU> References: <199508241251.IAA03008@gold.interlog.com> <MATT.95Aug24145052@physics2.Berkeley.EDU> Organization: CRL Dialup Internet Access (415) 705-6060 [Login: guest] Subject: Re: Equivalence of A and A<>