From -6004182548199292947
X-Google-Thread: f78e5,f1baa317914feeaf
X-Google-Attributes: gidf78e5,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news2.google.com!newshub.sdsu.edu!news.alt.net!frodo.cs.rpi.edu!not-for-mail
From: litb <Schaub-Johannes@web.de>
Newsgroups: comp.std.c++
Subject: Re: typeof keyword
Date: Wed, 25 Mar 2009 18:18:55 CST
Organization: http://groups.google.com
Lines: 24
Sender: cppmods@cs.rpi.edu
Approved: stephen.clamage@sun.com
Message-ID: <673d7f2d-bf05-4af5-8d09-e59907a6e4f5@g38g2000yqd.googlegroups.com>
References: <488de3d4-77ac-4c01-8130-d196dec70bc8@v15g2000yqn.googlegroups.com>
NNTP-Posting-Host: netlab.cs.rpi.edu
Content-Type: text/plain; charset=ISO-8859-1
To: (Usenet)
Return-Path: <cppmods@ruralroute.cs.rpi.edu>
X-Original-Date: Tue, 24 Mar 2009 16:46:09 -0700 (PDT)
X-Submission-Address: std-c++@netlab.cs.rpi.edu
Xref: g2news2.google.com comp.std.c++:340

On 25 Mrz., 01:06, eminha...@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.
>

Yeah, it's called decltype. It can give you the declared type of a
variable and type of expressions. Search in the working draft (
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2857.pdf )
for decltype. Useful for example in this case:

template<typename A, typename B> auto f(A const& a, B const& b) ->
decltype(a + b) { return a + b; }

Where we get the right return type without "clever" template trickery
and with simple code.

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



