From dd846658e6599ba2878a0fbed3c0c2e8891abbe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20J=C3=B6nsson?= Date: Sun, 10 May 2015 10:27:36 +0200 Subject: [PATCH] Use new kind of loop. --- PowerEditor/src/MISC/Common/Common.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 873ae4a5..98be1332 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -780,12 +780,11 @@ int stoiStrict(const generic_string& input) bool allLinesAreNumeric(const std::vector& lines) { - const auto endit = lines.end(); - for (auto it = lines.begin(); it != endit; ++it) + for (const generic_string& line : lines) { try { - stoiStrict(*it); + stoiStrict(line); } catch (std::invalid_argument&) { @@ -819,9 +818,9 @@ std::vector numericSort(std::vector input, bool { // Pre-condition: all strings in "input" are convertible to int with stoiStrict. std::vector inputAsInts; - for (auto it = input.begin(); it != input.end(); ++it) + for (const generic_string& line : input) { - inputAsInts.push_back(stoiStrict(*it)); + inputAsInts.push_back(stoiStrict(line)); } std::sort(inputAsInts.begin(), inputAsInts.end(), [isDescending](int a, int b) { @@ -835,9 +834,9 @@ std::vector numericSort(std::vector input, bool } }); std::vector output; - for (auto it = inputAsInts.begin(); it != inputAsInts.end(); ++it) + for (const int& sortedInt : inputAsInts) { - output.push_back(std::to_wstring(*it)); + output.push_back(std::to_wstring(sortedInt)); } return output; } \ No newline at end of file