File tree Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -450,12 +450,21 @@ C++ data structures
450
450
451
451
- Vector bounds checking is only enabled in debug mode. Do not rely on it
452
452
453
- - Make sure that constructors initialize all fields. If this is skipped for a
454
- good reason (i.e., optimization on the critical path), add an explicit
455
- comment about this
453
+ - Initialize all non-static class members where they are defined.
454
+ If this is skipped for a good reason (i.e., optimization on the critical
455
+ path), add an explicit comment about this
456
456
457
457
- * Rationale* : Ensure determinism by avoiding accidental use of uninitialized
458
458
values. Also, static analyzers balk about this.
459
+ Initializing the members in the declaration makes it easy to
460
+ spot uninitialized ones.
461
+
462
+ ``` cpp
463
+ class A
464
+ {
465
+ uint32_t m_count{0};
466
+ }
467
+ ```
459
468
460
469
- By default, declare single-argument constructors `explicit`.
461
470
@@ -474,18 +483,6 @@ C++ data structures
474
483
- *Rationale*: Easier to understand what is happening, thus easier to spot mistakes, even for those
475
484
that are not language lawyers
476
485
477
- - Initialize all non-static class members where they are defined
478
-
479
- - * Rationale* : Initializing the members in the declaration makes it easy to spot uninitialized ones,
480
- and avoids accidentally reading uninitialized memory
481
-
482
- ``` cpp
483
- class A
484
- {
485
- uint32_t m_count{0};
486
- }
487
- ```
488
-
489
486
Strings and formatting
490
487
------------------------
491
488
You can’t perform that action at this time.
0 commit comments