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


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

Re: Return type of function or expression

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: Return type of function or expression
Date 2012-02-07 18:08 +1300
Message-ID <9pbpu5FicgU8@mid.individual.net> (permalink)
References <6ea9f13e-061d-4b73-a3c3-502ebd3ea545@c20g2000vbb.googlegroups.com> <type-20120207053738@ram.dialup.fu-berlin.de>

Show all headers | 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