rspec/shared_content/cfamily/reference_over_nonnull_pointer.adoc
Philipp Dominik Schubert f45132d5aa
Modify rule S2637: Expand and adjust for LaYC
## Review

A dedicated reviewer checked the rule description successfully for:

- [x] logical errors and incorrect information
- [x] information gaps and missing content
- [x] text style and tone
- [x] PR summary and labels follow [the
guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)

---------

Co-authored-by: Arseniy Zaostrovnykh <arseniy.zaostrovnykh@sonarsource.com>
2023-10-04 13:02:47 +02:00

15 lines
392 B
Plaintext

In {cpp}, it is preferred to use reference parameters (`Type const&` or `Type&`), or pass objects by value (`Type`), instead of a pointer (`Type const*` or `Type*`), if the argument is expected to never be null.
[source,cpp]
----
// Precondition: graph != null
bool isDAG(Graph const* graph);
----
The preferred signature would be:
[source,cpp]
----
bool isDAG(Graph const& graph);
----