Commit 80b80d85 authored by scott snyder's avatar scott snyder
Browse files

recommend range-based for. Bump version to 0.5.

parent ef2608f4
#+MACRO: version 0.4
#+LaTeX_HEADER: \def\rulesversion{0.4}
#+MACRO: version 0.5
#+LaTeX_HEADER: \def\rulesversion{0.5}
#+TITLE: ATLAS C++ coding guidelines, version {{{version}}}
#+AUTHOR: Shaun Roe (CERN), Scott Snyder (BNL), and the former ATLAS Quality Control group
#+EMAIL: Correspondence to
......@@ -433,6 +433,34 @@ vector<int> x; // Missing std!
change the loop variable within the loop body rather than inside the
expression executed after each iteration.
- *Prefer range-based for loops.* [<<prefer-range-based-for>>]
C++11 introduced the `range-based for'. Prefer using this to a loop
with explicit iterators; that is, prefer:
std::vector<int> v = ...;
for (int x : v) {
doSomething (x);
std::vector<int> v = ...;
for (std::vector<int>::const_iterator it = v.begin();
it != v.end();
doSomething (*it);
In some cases you can't make this replacement; for example, if you
need to call methods on the iterator itself, or you need to manage
multiple iterators within the loop. But most simple loops over
STL ranges are most simply written with a range-based for.
- *All switch statements must have a default clause.* [<<switch-default>>]
In some cases the default clause can never be reached because there
......@@ -2848,6 +2876,7 @@ The comment includes the fact that it is the perpendicular distance.
** Version 0.5
- Add an initial set of guidelines for AthenaMT.
- Add recommendation to prefer range-based for.
** Version 0.4
- Minor updates: we're now using c++14. Add note about implicit fallthrough
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment