Add a style rule about not using const optional<T>& arguments
Motivated by discussions here: https://webrtc-review.googlesource.com/c/src/+/109583 Bug: none Change-Id: Ia0723adf9fa7c970137ffc9cb5612cb3360d7f5f Notry: true Reviewed-on: https://webrtc-review.googlesource.com/c/109568 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25556}
This commit is contained in:
@ -77,6 +77,18 @@ instead of | use
|
||||
|
||||
See [the source](api/array_view.h) for more detailed docs.
|
||||
|
||||
### `absl::optional<T>` as function argument
|
||||
|
||||
`absl::optional<T>` is generally a good choice when you want to pass a
|
||||
possibly missing `T` to a function—provided of course that `T`
|
||||
is a type that it makes sense to pass by value.
|
||||
|
||||
However, when you want to avoid pass-by-value, generally **do not pass
|
||||
`const absl::optional<T>&`; use `const T*` instead.** `const
|
||||
absl::optional<T>&` forces the caller to store the `T` in an
|
||||
`absl::optional<T>`; `const T*`, on the other hand, makes no
|
||||
assumptions about how the `T` is stored.
|
||||
|
||||
### sigslot
|
||||
|
||||
sigslot is a lightweight library that adds a signal/slot language
|
||||
|
Reference in New Issue
Block a user