Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #13810

Re: Return type of function or expression

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: Return type of function or expression
Date Tue, 07 Feb 2012 18:08:21 +1300
Lines 40
Message-ID <9pbpu5FicgU8@mid.individual.net> (permalink)
References <6ea9f13e-061d-4b73-a3c3-502ebd3ea545@c20g2000vbb.googlegroups.com> <type-20120207053738@ram.dialup.fu-berlin.de>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 8bit
X-Trace individual.net CjZPfJ8mf1gWWNlTbXjQXwJIKX9KL22D06SpnyZukK6qH0jtb3
Cancel-Lock sha1:35H9OGDnx8I8I7d9pmSQQn7oK30=
User-Agent Mozilla/5.0 (X11; SunOS i86pc; rv:6.0.2) Gecko/20111003 Thunderbird/6.0.2
In-Reply-To <type-20120207053738@ram.dialup.fu-berlin.de>
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:13810

Show key headers only | View raw


On 02/ 7/12 05:39 PM, Stefan Ram wrote:
> GH<yzghan@gmail.com>  writes:
>> Hi all, is there a way to statically reference the return type of a
>> function or expression?
>
>    An expression has a type (not a return type).
>
>> To make myself clear, take the iomanip
>> std::setw for example
>
>    »The« requires an English noun. If I want to use
>    »iomanip std::setw« as a name, I use it without »the«.

If you are being pedantic, iomanip being short for I/O manipulator can 
be used as a noun.

>> . The standard explicitly leaves the return type
>> of std::setw implementation dependent.
>
>    It is T6, an »unspecified implementation type«.
>
>> Suppose I want to know and reference the type of std::setw(8)
>> (e g create a variable of that type), is there anyway to
>> reference that type without going to the headers and using
>> the implementation dependent type such as std::_Setw in g++?
>
>    Assume that this would be possible, so you could write

Which you can with the new decltype operator.

> { RETURNTYPEOF(std::setw) e; ... }
>
>    to declare the variable e of that type, which is unknown
>    to you, the programmer. What operations could you apply
>    to »e« in »...« that case? What could you do with it?

Very useful inn conjunction with the new suffix return type syntax.

-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Return type of function or expression GH <yzghan@gmail.com> - 2012-02-04 07:29 -0800
  Re: Return type of function or expression darylew@gmail.com - 2012-02-04 12:34 -0800
    Re: Return type of function or expression Ian Collins <ian-news@hotmail.com> - 2012-02-07 17:29 +1300
  Re: Return type of function or expression Ian Collins <ian-news@hotmail.com> - 2012-02-07 18:08 +1300

csiph-web