STYLE: Use range-based loops from C++11

C++11 Range based for loops can be used in

Used as a more readable equivalent to the traditional for loop operating over a
range of values, such as all elements in a container, in the forward direction..

Range based loopes are more explicit for only computing the
end location once for containers.

SRCDIR=/Users/johnsonhj/src/jsoncpp/ #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-loop-convert  -header-filter=.* -fix
This commit is contained in:
Hans Johnson
2019-01-14 17:09:12 -06:00
committed by Hans Johnson
parent 3beadff472
commit cbeed7b076
5 changed files with 11 additions and 28 deletions

View File

@@ -110,9 +110,7 @@ static void printValueTree(FILE* fout,
Json::Value::Members members(value.getMemberNames());
std::sort(members.begin(), members.end());
JSONCPP_STRING suffix = *(path.end() - 1) == '.' ? "" : ".";
for (Json::Value::Members::iterator it = members.begin();
it != members.end(); ++it) {
const JSONCPP_STRING name = *it;
for (auto name : members) {
printValueTree(fout, value[name], path + suffix + name);
}
} break;