You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update functions.md
Signed-off-by: Neil Henderson <[email protected]>
* Tweak comments for divide example
---------
Signed-off-by: Neil Henderson <[email protected]>
Co-authored-by: Herb Sutter <[email protected]>
Copy file name to clipboardExpand all lines: docs/cpp2/functions.md
+25-3Lines changed: 25 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
4
4
## Overview
5
5
6
-
A function is defined by writing a function signature after the `:` and a statement (expression or `{``}` compound statement) after the `=`. After the optional [template parameters](declarations.md#template-parameters) available for all declarations, a function signatures consists of a possibly-empty [parameter list](#parameters), and an optional function[return values](#return-values).
6
+
A function is defined by writing a function signature after the `:` and a statement (expression or `{``}` compound statement) after the `=`. After the optional [template parameters](declarations.md#template-parameters) available for all declarations, a function signature consists of a possibly-empty [parameter list](#parameters), and one or more optional[return values](#return-values).
7
7
8
8
For example, the minimal function named `func` that takes no parameters and returns nothing (`#!cpp void`) is:
9
9
@@ -14,7 +14,7 @@ func: ( /* no parameters */ ) = { /* empty body */ }
14
14
15
15
## <a id="parameters"></a> Parameters
16
16
17
-
The parameter list is enclosed by `(` `)` parentheses, and the parameters separated by commas. Each parameter is declared using the [same syntax as any object](declarations.md). For example:
17
+
The parameter list is enclosed by `(` `)` parentheses and the parameters are separated by commas. Each parameter is declared using the [same unified syntax](declarations.md) as used for all declarations. For example:
(2) **`#!cpp -> ( /* parameter list */ )`** to return a list of named return parameters using the same [parameters](#parameters) syntax, but where the only passing styles are `out` (the default, which moves where possible) or `forward`. The function body must [initialize](objects.md#init) the value of each return-parameter `ret` in its body the same way as any other local variable. An explicit return statement is written just `#!cpp return;` and returns the named values; the function has an implicit `#!cpp return;` at the end. For example:
0 commit comments