diff options
| author | Wladimir J. van der Laan <[email protected]> | 2016-06-10 11:29:17 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2016-06-10 11:29:36 +0200 |
| commit | 67db011e12596b44fdf5e4c6033514f189abf0ce (patch) | |
| tree | b94367feafb967521cfed376dbf72be2d62132f1 /doc/developer-notes.md | |
| parent | qt: translations update (diff) | |
| parent | developer notes: updates for C++11 (diff) | |
| download | discoin-67db011e12596b44fdf5e4c6033514f189abf0ce.tar.xz discoin-67db011e12596b44fdf5e4c6033514f189abf0ce.zip | |
Merge #8177: developer notes: updates for C++11
654a211 developer notes: updates for C++11 (Kaz Wesley)
Diffstat (limited to 'doc/developer-notes.md')
| -rw-r--r-- | doc/developer-notes.md | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/doc/developer-notes.md b/doc/developer-notes.md index abed15c37..95c46b05f 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -265,7 +265,7 @@ General C++ 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 - `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 @@ -284,10 +284,9 @@ C++ data structures - *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 -- Watch out for vector out-of-bounds exceptions. `&vch[0]` is illegal for an - empty vector, `&vch[vch.size()]` is always illegal. Use `begin_ptr(vch)` and - `end_ptr(vch)` to get the begin and end pointer instead (defined in - `serialize.h`) +- Watch out for out-of-bounds vector access. `&vch[vch.size()]` is illegal, + including `&vch[0]` for an empty vector. Use `vch.data()` and `vch.data() + + vch.size()` instead. - Vector bounds checking is only enabled in debug mode. Do not rely on it |