Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #67833 > unrolled thread
| Started by | "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> |
|---|---|
| First post | 2019-08-21 04:59 +0200 |
| Last post | 2019-08-22 05:05 -0700 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.c++
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
| From | "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> |
|---|---|
| Date | 2019-08-21 04:59 +0200 |
| Subject | Explicitly 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]
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Date | 2019-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