Article View: comp.std.c++
Article #1835Re: Equivalence of A and A<>
From: Herb Sutter
Date: Thu, 24 Aug 1995 14:29
Date: Thu, 24 Aug 1995 14:29
36 lines
1880 bytes
1880 bytes
gcato@st6000.sct.edu (Vaughn Cato) wrote:
>I am curious as to the reasoning behind disallowing the use of a template
>name as a synonym for a template id with no template parameters:
>
>template <class T = int> class A;
>
>void f()
>{
> A<> *p1; // The legal way to default the argument
> A *p2; // Syntax error
>}
If the latter was allowed, it would be ambiguous if a non-templated class A
existed.
If we allowed it anyway and just told the compiler to complain about
ambiguities, then the above code would break the moment an unrelated class A
visible to this function was created... bad side effect.
>This parallels with
>the function call syntax, which requires ()'s to be used even when no
>actual parameters are passed.
Exactly, for similar reasons: it would be odd if your code suddenly broke
(became ambiguous and uncompilable) if someone added a variable that happened
to have the same name as a function you're using... without (), it wouldn't be
possible to differentiate the two.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herb Sutter 2228 Urwin, Ste 102 voice (416) 618-0184
Connected Object Solutions Oakville ON Canada L6L 2T2 fax (905) 847-6019
---
[ 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:
<199508241251.IAA03008@gold.interlog.com>Path:
arc1-ca.pugleaf.net!in2.uu.net!bounce-backShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back Date: 24 Aug 95 14:29:18 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Return-Path: <daemon@ncar.UCAR.EDU> Message-ID: <199508241251.IAA03008@gold.interlog.com> From: herbs@interlog.com (Herb Sutter) Subject: Re: Equivalence of A and A<> Organization: Daystar Software Systems Design Inc. X-Original-Date: Thu, 24 Aug 95 12:56:36 GMT