Skip to content

[SUGGESTION] Move by default for in parameters? #114

Closed
@tylerjw

Description

@tylerjw

Ever since the introduction of move semantics a ton of boilerplate code has been written to enable moving the ownership of variables into arguments to functions or constructors.

Have you considered making in-parameters move by default with explicit syntax for creating a copy when the user would prefer to not move the ownership of a variable into the scope of a function?

In many cases moving into a parameter is the correct choice but the current syntax for doing that correctly is difficult to learn and use correctly.

One side-effect of doing this would mean that to maintain safety the compiler would need to detect when someone used a variable after they moved it. clang-tidy does have a check for this: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-after-move.html

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions