Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 49b32af

Browse filesBrowse files
addaleaxtargos
authored andcommitted
doc: document nullptr comparisons in style guide
This documents existing practices. PR-URL: #23805 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
1 parent 5c35d0d commit 49b32af
Copy full SHA for 49b32af

File tree

Expand file treeCollapse file tree

1 file changed

+7
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-0
lines changed
Open diff view settings
Collapse file

‎CPP_STYLE_GUIDE.md‎

Copy file name to clipboardExpand all lines: CPP_STYLE_GUIDE.md
+7Lines changed: 7 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* [Memory Management](#memory-management)
1919
* [Memory allocation](#memory-allocation)
2020
* [Use `nullptr` instead of `NULL` or `0`](#use-nullptr-instead-of-null-or-0)
21+
* [Use explicit pointer comparisons](#use-explicit-pointer-comparisons)
2122
* [Ownership and Smart Pointers](#ownership-and-smart-pointers)
2223
* [Avoid non-const references](#avoid-non-const-references)
2324
* [Others](#others)
@@ -195,6 +196,12 @@ class FancyContainer {
195196

196197
Further reading in the [C++ Core Guidelines][ES.47].
197198

199+
### Use explicit pointer comparisons
200+
201+
Use explicit comparisons to `nullptr` when testing pointers, i.e.
202+
`if (foo == nullptr)` instead of `if (foo)` and
203+
`foo != nullptr` instead of `!foo`.
204+
198205
### Ownership and Smart Pointers
199206

200207
* [R.20]: Use `std::unique_ptr` or `std::shared_ptr` to represent ownership

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.