Skip to content

Commit 44a93cb

Browse files
committed
Extend examples for [dcl.spec.auto.general]
Signed-off-by: Mauro Russo <[email protected]>
1 parent d017ce4 commit 44a93cb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

source/declarations.tex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,15 @@
18361836
auto g() { return 0.0; } // OK, \tcode{g} returns \tcode{double}
18371837
auto (*fp)() -> auto = f; // OK
18381838
auto h(); // OK, \tcode{h}'s return type will be deduced when it is defined
1839+
auto j() -> auto; // OK, deduction of \tcode{j}'s return type postponed at the definition
1840+
auto (*jp)() -> auto = j; // error, cannot use \tcode{j}'s before deducing its return type
1841+
auto (*kp)() -> auto; // error, not a function declaration; needs an initializer
1842+
constexpr auto l =
1843+
[](auto (*fp)() -> auto) // OK, \tcode{l}'s parameter \tcode{fp} is a function pointer,
1844+
{ return fp; }; // whose return type will be deduced when \tcode{l} is invoked
1845+
int foo();
1846+
static_assert(l(foo) == foo); // OK
1847+
18391848
\end{codeblock}
18401849
\end{example}
18411850
The \keyword{auto} \grammarterm{type-specifier}

0 commit comments

Comments
 (0)