rspec/shared_content/cfamily/reference_over_nonnull_pointer.adoc

15 lines
392 B
Plaintext
Raw Normal View History

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);
----