From -2808869833006422772
X-Google-Thread: f78e5,f1baa317914feeaf
X-Google-Attributes: gidf78e5,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news1.google.com!newsfeed.stanford.edu!news.kjsl.com!news.alt.net!frodo.cs.rpi.edu!not-for-mail
From: "Joe Smith" <unknown_kev_cat@hotmail.com>
Newsgroups: comp.std.c++
Subject: Re: typeof keyword
Date: Wed, 25 Mar 2009 18:28:44 CST
Organization: Mixmin
Lines: 32
Sender: cppmods@cs.rpi.edu
Approved: stephen.clamage@sun.com
Message-ID: <gqdl38$gtu$1@news.mixmin.net>
References: <488de3d4-77ac-4c01-8130-d196dec70bc8@v15g2000yqn.googlegroups.com>
NNTP-Posting-Host: netlab.cs.rpi.edu
Content-Type: text/plain;
	format=flowed;
	charset="iso-8859-1";
	reply-type=original
To: (Usenet)
Return-Path: <cppmods@ruralroute.cs.rpi.edu>
X-Original-Date: Wed, 25 Mar 2009 12:00:17 -0400
X-Submission-Address: std-c++@netlab.cs.rpi.edu
Xref: g2news2.google.com comp.std.c++:341


<eminhanif@googlemail.com> wrote:
> hi,
> i was wondering if a typeof keyword is going to be defined in the new
> standard?
> i, personnally, would find it very helpful.
>

If what you are wanting is something like the following, you are in luck:

int main()
{
int i;
typeof(i) j;
}

(i.e. the typeof() operator acts as the type of the expression so it can be
used to define new variables of that type)

What you are looking for is decltype(), which works exactly like you would
expect ("decltype(i) j;"). It is new in C++0x, but already available in the
latest versions of some compilers. (for example it is present in the latest
Comeau C++ beta, as well as the latest gcc).



-- 
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



