mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
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:
1 parent
a2328da1c4
commit
24cb1f33d8
1 file changed
+7
@@ -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
|
||||
|
||||
Reference in new issue
Block a user