Skip to content

Commit

Permalink
Add passing styles to single type return (#1274)
Browse files Browse the repository at this point in the history
Resolves #1205  Suggestion 1, suggest making new elements for 2 and 3.

Signed-off-by: gregmarr <[email protected]>
  • Loading branch information
gregmarr authored Sep 23, 2024
1 parent 8879d13 commit ac2196b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/cpp2/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ wrap_f: (

A function can return either of the following. The default is `#!cpp -> void`.

(1) **`#!cpp -> X`** to return a single unnamed value of type `X`, which can be `#!cpp void` to signify the function has no return value. If `X` is not `#!cpp void`, the function body must have a `#!cpp return /*value*/;` statement that returns a value of type `X` on every path that exits the function.
(1) **`#!cpp -> X`** to return a single unnamed value of type `X` using the same passing styles from the [parameters](#parameters) syntax, but where the only passing styles are `move` (the default) or `forward`. The type can be `#!cpp void` to signify the function has no return value. If `X` is not `#!cpp void`, the function body must have a `#!cpp return /*value*/;` statement that returns a value of type `X` on every path that exits the function.

To deduce the return type, write `-> _`. A function whose body returns a single expression `expr` can deduce the return type, and omit writing the leading `-> _ = { return` and trailing `; }`.

Expand Down

0 comments on commit ac2196b

Please sign in to comment.