Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
developer notes: updates for C++11
Browse files Browse the repository at this point in the history
- boost::scoped_ptr is obsolete
- std::vector::data replaces begin_ptr / end_ptr
  • Loading branch information
kazcw committed Jun 9, 2016
1 parent 52c3f34 commit 654a211
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 654a211

Please sign in to comment.