summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CPP_STYLE_GUIDE.md7
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