From -5387795378469953271 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,ede379f5dbbc1549 X-Google-Attributes: gidf78e5,public From: Max TenEyck Woodbury Subject: Re: Suggestion: "typeof" keyword Date: 1999/08/23 Message-ID: <37BD9F42.29FB78C@cds.duke.edu>#1/1 X-Deja-AN: 516089514 Content-Transfer-Encoding: 7bit Approved: Fergus Henderson References: <7nt3vl$1oe$1@nnrp1.deja.com> <7oh7o8$t3f$1@nnrp1.deja.com> <7ol6hi$ej9$2@news.BelWue.DE> <120819991357412479%lisa_lippincott@advisories.com> <37BBDDCA.90D590D4@physik.tu-muenchen.de> X-Original-Date: Fri, 20 Aug 1999 14:32:34 -0400 X-Accept-Language: en X-Authentication-Warning: backdraft.briar.org: smap set sender to using -f Content-Type: text/plain; charset=us-ascii X-Complaints-To: news@news.unimelb.edu.au X-Trace: izvestia.its.unimelb.edu.au 935398153 27508 128.250.29.17 (23 Aug 1999 08:49:12 GMT) Organization: Duke University, Durham, NC, USA X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN8EK7eEDnX0m9pzZAQHL+wF+KO2UuytIgOtEP0KQanf//ZK4xjw+uxlj mLE6WBBJ0YgGCgB5eww7KV3eQ32Ag2aa =2eSd Mime-Version: 1.0 NNTP-Posting-Date: 23 Aug 1999 08:49:12 GMT Newsgroups: comp.std.c++ Christopher Eltschka wrote: > > "Siemel B. Naran" wrote: > > > > On 13 Aug 99 15:52:23 GMT, Lisa Lippincott > > > > >/* what type goes here? */ > > >MultiplyAdd( const A& a, const B& b, const C& c ) > > > { return a * b + c; } > > > > In one of my posts I used this > > typeof(A*B+C) MultiplyAdd(...) { ... } > > That's problematic: > > class X {}; > class Y { Y operator*(); }; > X operator*(X, Y); > Y operator*(X*, Y); > > typeof(X**Y) a > > Is a of type X or of type Y? > (That is, is the first star the multiplication operator and the > second one the dereference operator, or is the first one part of > the type, making a pointer to X, and the second one the > multiplication operator?) You need a slightly different syntax to distinguish the use of an expression from the use of a type, as sizeof does. Since typeof is not needed in the direct type specification case, it can be used to get the type of function signatures. For example: typedef typeof operator *(X,Y) XY; // = X typedef typeof operator *(X*,Y) pXY; // = Y mtew@cds.duke.edu --- [ 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 ]