From 7962662912317021813
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ede379f5dbbc1549
X-Google-Attributes: gidf78e5,public
From: "Darin Adler" <darin@bentspoon.com>
Subject: Re: Suggestion: "typeof" keyword
Date: 1999/08/24
Message-ID: <7puugq$4dn@enews1.newsguy.com>#1/1
X-Deja-AN: 516771653
X-NNTP-Posting-Host: news.newsdawg.com
Content-Transfer-Encoding: 7bit
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <7nt3vl$1oe$1@nnrp1.deja.com> <7oh7o8$t3f$1@nnrp1.deja.com> <7ol6hi$ej9$2@news.BelWue.DE> <cTiioXAhAwr3Ew$X@robinton.demon.co.uk> <t7d7ww1vrz.fsf@calumny.jyacc.com> <e4DSyfA4ALs3Ew0Q@robinton.demon.co.uk> <t7r9laz5hj.fsf@calumny.jyacc.com> <7oup0a$8g2$1@nnrp1.deja.com> <37B3C2AD.5AB722AE@lucent.com> <37B5A571.449B@wanadoo.fr> <37B908A8.717CAC2C@lucent.com> <CVJFZFAbaWu3Ew15@robinton.demon.co.uk> <7pcvjs$tk4$1@nnrp1.deja.com> <user-1808991258230001@aus-as3-121.io.com> <7phk8n$b26$1@nnrp1.deja.com> <37BD2185.C0047293@physik.tu-muenchen.de> <7pk6r6$689$1@nnrp1.deja.com> <37C1B67F.B5B0B51A@cds.duke.edu> <230819991621180849%lisa_lippincott@advisories.com> <t71zcthzrd.fsf@calumny.jyacc.com>
X-UID: 0000000001
X-Status: $$$T
Content-Type: text/plain; charset="US-ASCII"
Organization: http://extra.newsguy.com
Mime-Version: 1.0
Newsgroups: comp.std.c++
Originator: clamage@taumet


Lisa Lippincott <lisa_lippincott@advisories.com> writes:
>> Here's a potential trouble spot with typeof: it allows a program to refer
>> to unnamed classes and enums, which may cause havoc with linkage.
>> Consider:
>>
>> enum {a};
>> enum {b};
>> void f( typeof(a) );
>> void f( typeof(b) );
>>
>> What are the linkage names of the functions f?

Hyman Rosen <hymie@prolifics.com> wrote:
> Is the following illegal? Gcc compiles it without error or warning.
>
> #include <iostream>
> enum { a }; enum { b };
> template <typename T> void f(T v) { cout << v << endl; }
> int main() { f(a); f(b); }

Other than the lack of "std::" before "cout" and "endl", I don't see
anything wrong with the code above.

On the other hand, your example doesn't address the point of Lisa's example.

Your example calls the std::basic_ostream<> inserter for one of the integral
types. Since there's no exact match for the anonymous enum type, overload
matching performs standard conversions, which include integral promition of
an rvalue of enumerated type to int, unsigned int, long, or unsigned long.

    -- Darin


[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




