cpp/language/return

Terminates the current function and returns the specified value (if any) to the caller.

Explanation
@1@ Evaluates the, terminates the current function and returns the result of the to the caller, after  to the function return type. The is optional in functions whose return type is (possibly cv-qualified), and disallowed in constructors and in destructors.

@2@ Uses to construct the return value of the function.

@3,4@ In a coroutine, the keyword co_return must be used instead of return for the final suspension point (see for details).

Automatic move from local variables and parameters
The is move-eligible if it is a (possibly parenthesized)  that names a variable of automatic storage duration whose type is
 * a non-volatile object type

and that variable is declared
 * in the body or
 * as a parameter of
 * the innermost enclosing function or lambda expression.

}}

{{rrev|since=c++17|

Guaranteed copy elision
If is a prvalue, the result object is initialized directly by that expression. This does not involve a copy or move constructor when the types match (see ). }}

Keywords
,