doc: document nullptr comparisons in style guide

This documents existing practices.

PR-URL: https://github.com/nodejs/node/pull/23805
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
This commit is contained in:
Anna Henningsen authored and Michaël Zasso committed 2018-11-01 21:47:11 +01:00
1 parent 5c35d0db47
commit 49b32af5ab
1 file changed
+7
+7
View File
@@ -18,6 +18,7 @@
* [Memory Management](#memory-management)
* [Memory allocation](#memory-allocation)
* [Use `nullptr` instead of `NULL` or `0`](#use-nullptr-instead-of-null-or-0)
* [Use explicit pointer comparisons](#use-explicit-pointer-comparisons)
* [Ownership and Smart Pointers](#ownership-and-smart-pointers)
* [Avoid non-const references](#avoid-non-const-references)
* [Others](#others)
@@ -195,6 +196,12 @@ class FancyContainer {
Further reading in the [C++ Core Guidelines][ES.47].
### Use explicit pointer comparisons
Use explicit comparisons to `nullptr` when testing pointers, i.e.
`if (foo == nullptr)` instead of `if (foo)` and
`foo != nullptr` instead of `!foo`.
### Ownership and Smart Pointers
* [R.20]: Use `std::unique_ptr` or `std::shared_ptr` to represent ownership