diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-10-21 18:55:30 +0200 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-10-25 05:49:25 +0200 |
commit | 24cb1f33d85fbb8e5cc9c10f488766ca8a21ddca (patch) | |
tree | e429fbca7f3c6e254c6dbcf91cb9cbbe937211c8 /CPP_STYLE_GUIDE.md | |
parent | a2328da1c4d7f0072292eeb14ace0281d7b08d55 (diff) | |
download | android-node-v8-24cb1f33d85fbb8e5cc9c10f488766ca8a21ddca.tar.gz android-node-v8-24cb1f33d85fbb8e5cc9c10f488766ca8a21ddca.tar.bz2 android-node-v8-24cb1f33d85fbb8e5cc9c10f488766ca8a21ddca.zip |
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>
Diffstat (limited to 'CPP_STYLE_GUIDE.md')
-rw-r--r-- | CPP_STYLE_GUIDE.md | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/CPP_STYLE_GUIDE.md b/CPP_STYLE_GUIDE.md index e14de6cc48..5099f34ea8 100644 --- a/CPP_STYLE_GUIDE.md +++ b/CPP_STYLE_GUIDE.md @@ -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 |