From -4137202538488541094
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ede379f5dbbc1549
X-Google-Attributes: gidf78e5,public
From: fjh@cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: Suggestion: "typeof" keyword
Date: 1999/08/29
Message-ID: <7q90mb$pqr$1@mulga.cs.mu.OZ.AU>#1/1
X-Deja-AN: 518351514
X-Nntp-Posting-Host: mundook.cs.mu.oz.au
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> <37C3F3C5.CAA574E8@physik.tu-muenchen.de>
Organization: Computer Science, The University of Melbourne
X-UID: 0000000001
X-Status: $$$T
Newsgroups: comp.std.c++
Originator: clamage@taumet


Christopher Eltschka <celtschk@physik.tu-muenchen.de> writes:

>niklasb@my-deja.com wrote:
>> 
>> You've convinced me. The reference should be stripped,
>> but the CV qualifier should be retained. Just to give
>> something concrete to talk about, let me try once again
>> to suggest a set of rules:
...
>> 3 Within the context of a typeof expression, a temporary
>>   object of any type T can be instantiated using
>> 
>>    - initialization notation, T(), whether or not
>>      T has a default constructor, or
>> 
>>    - cast notation, (T)expr, whether or not a
>>      conversion from typeof(expr) to T exists.

Why allow both of these?  Surely allowing one of them would be sufficient.

I still don't see why any of these is better than `*(T*)NULL'.

>I'd restrict this to special expressions; a good candidate
>would be the same as currently the null pointer constant,
>since this already is very special.
>
>Thus in typeof expressions
>
>  (T)0  would be legal and an rvalue
>  (T&)0 would be legal and an lvalue

You could use `(T)*(T*)NULL' for a null pointer, although admittedly that
is not particularly pleasant syntax.

I think the need to distinguish between rvalues and lvalues would be rare.

If you don't like that syntax, you can easily define template functions

	template <class T> T rvalue();
	template <class T> T& lvalue();

and then use `rvalue<T>()' and `lvaue<T>()'.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3        |     -- the last words of T. S. Garp.


[ 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              ]




