From 8189257674625092958 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,ede379f5dbbc1549 X-Google-Attributes: gidf78e5,public From: postmast.root.admi.gov@iname.com (blargg) Subject: Re: Suggestion: "typeof" keyword Date: 1999/08/24 Message-ID: #1/1 X-Deja-AN: 516623122 X-NNTP-Posting-Host: aus-as3-091.io.com 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> <7oup0a$8g2$1@nnrp1.deja.com> <37B3C2AD.5AB722AE@lucent.com> <37B5A571.449B@wanadoo.fr> <37B908A8.717CAC2C@lucent.com> <7pcvjs$tk4$1@nnrp1.deja.com> <7phk8n$b26$1@nnrp1.deja.com> <37BD2185.C0047293@physik.tu-muenchen.de> <7pk6r6$689$1@nnrp1.deja.com> <37C1B67F.B5B0B51A@cds.duke.edu> X-UID: 0000000001 X-Status: $$$T X-Complaints-To: abuse@io.com X-Trace: hiram.io.com 935456836 18160 208.2.106.91 (24 Aug 1999 01:07:16 GMT) Organization: e-mail address IS valid - but fools the spammers NNTP-Posting-Date: 24 Aug 1999 01:07:16 GMT Newsgroups: comp.std.c++ Originator: clamage@taumet In article <37C1B67F.B5B0B51A@cds.duke.edu>, Max TenEyck Woodbury wrote: > 'const' and 'volatile' are distinct attributes from the basic type > of a data item. If they appear at the top level, they should be > removed. After all, the main purpose of 'typeof' is to allow > correctly typed copies to be instanced. One of the reasons for > making the copy of something is to manipulate it in some way while > leaving the original unchanged. Preserving 'const' at the top level > could prevent this. > > In the one bad example given, some trouble was taken to throw away > 'const' at a lower level. > > The original was > > > any_type foo; > > typeof(foo)* bar = &foo; > > > > And now assume any_type is int const. > > The correct way to do this would be: > > any_type foo; > typeof(&foo) bar = &foo; > > With any_type as int const, bar's type is * int const. And one could remove the pointer and get a real const int from that: template struct derefed_type; template struct derefed_type { typedef T type; }; typename derefed_type::type bar = foo; // bar->const int I'm still for object allowed on LHS of scope resolution operator :: that typeof () could be implemented on top of by the user. [ 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 ]