mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Merge #8177: developer notes: updates for C++11
654a211
developer notes: updates for C++11 (Kaz Wesley)
This commit is contained in:
commit
67db011e12
@ -265,7 +265,7 @@ General C++
|
|||||||
the `.h` to the `.cpp` should not result in build errors
|
the `.h` to the `.cpp` should not result in build errors
|
||||||
|
|
||||||
- Use the RAII (Resource Acquisition Is Initialization) paradigm where possible. For example by using
|
- Use the RAII (Resource Acquisition Is Initialization) paradigm where possible. For example by using
|
||||||
`scoped_pointer` for allocations in a function.
|
`unique_ptr` for allocations in a function.
|
||||||
|
|
||||||
- *Rationale*: This avoids memory and resource leaks, and ensures exception safety
|
- *Rationale*: This avoids memory and resource leaks, and ensures exception safety
|
||||||
|
|
||||||
@ -284,10 +284,9 @@ C++ data structures
|
|||||||
- *Rationale*: Behavior is undefined. In C++ parlor this means "may reformat
|
- *Rationale*: Behavior is undefined. In C++ parlor this means "may reformat
|
||||||
the universe", in practice this has resulted in at least one hard-to-debug crash bug
|
the universe", in practice this has resulted in at least one hard-to-debug crash bug
|
||||||
|
|
||||||
- Watch out for vector out-of-bounds exceptions. `&vch[0]` is illegal for an
|
- Watch out for out-of-bounds vector access. `&vch[vch.size()]` is illegal,
|
||||||
empty vector, `&vch[vch.size()]` is always illegal. Use `begin_ptr(vch)` and
|
including `&vch[0]` for an empty vector. Use `vch.data()` and `vch.data() +
|
||||||
`end_ptr(vch)` to get the begin and end pointer instead (defined in
|
vch.size()` instead.
|
||||||
`serialize.h`)
|
|
||||||
|
|
||||||
- Vector bounds checking is only enabled in debug mode. Do not rely on it
|
- Vector bounds checking is only enabled in debug mode. Do not rely on it
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user