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


Groups > comp.lang.c++ > #67833 > unrolled thread

Explicitly deduced return type (like "auto foo() -> auto"), is that valid?

Started by"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>
First post2019-08-21 04:59 +0200
Last post2019-08-22 05:05 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.c++


Contents

  Explicitly deduced return type (like "auto foo() -> auto"), is that valid? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-08-21 04:59 +0200
    Re: Explicitly deduced return type (like "auto foo() -> auto"), is that valid? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-08-22 05:05 -0700

#67833 — Explicitly deduced return type (like "auto foo() -> auto"), is that valid?

From"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>
Date2019-08-21 04:59 +0200
SubjectExplicitly deduced return type (like "auto foo() -> auto"), is that valid?
Message-ID<qjic31$9ik$1@dont-email.me>
Specifically, is

     auto foo() -> auto { return 42; }

     auto main() -> int
     {
         return foo();
     }

... valid?

I'd guess that it's not valid as C++11, but possibly valid as C++14 or 
later.

It compiles with Visual C++ 2019 and g++ 9.2.


Cheers!,

- Alf

[toc] | [next] | [standalone]


#67870

FromTim Rentsch <tr.17687@z991.linuxsc.com>
Date2019-08-22 05:05 -0700
Message-ID<86zhk1h0cr.fsf@mailhub.linuxsc.com>
In reply to#67833
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> writes:

> Specifically, is
>
>     auto foo() -> auto { return 42; }
>
>     auto main() -> int
>     {
>         return foo();
>     }
>
> ... valid?
>
> I'd guess that it's not valid as C++11, but possibly valid as
> C++14 or later.

fwiw, g++ and clang accept it without complaint under -std=c++14
and -std=c++17, but give a diagnostic under -std=c++11.  That
result holds both with and without a -pedantic option.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c++


csiph-web