Skip to content

Allow passing arguments by reference #718

Open
@eggrobin

Description

@eggrobin

The current style conflicts with our avoidance of pointers where the address is unneeded (and the wole "& is visible" argument is fallacious since many things are pointers already, and sometimes we're actually using the pointer).

Decision

Avoid taking the address of a reference wherever possible (exceptions include standard library functions that only return by reference).
member variables and contents of containers should not be references (or std::cref, std::ref).
Use T& arg instead of not_null<T*> arg when the callee does not need to use the pointer. Note that since we forbid storing the reference, only the pointer may be stored; this means that when a function is called with a reference, the lifetime of the reference is not a concern.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions