From: Richard Kimberly Heck Date: Fri, 28 Feb 2020 06:48:10 +0000 (-0500) Subject: Use ranges, fix warning X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f2a4a4220965cf6963adae42dd650599c8d5e3eb;p=features.git Use ranges, fix warning --- diff --git a/src/Counters.cpp b/src/Counters.cpp index 2daac53224..830a1002ca 100644 --- a/src/Counters.cpp +++ b/src/Counters.cpp @@ -184,7 +184,7 @@ Counter::StringMap & Counter::flatLabelStrings(bool in_appendix) const Counters::Counters() : appendix_(false), subfloat_(false), longtable_(false) { - layout_stack_.push_back(0); + layout_stack_.push_back(nullptr); counter_stack_.push_back(from_ascii("")); } @@ -265,14 +265,12 @@ int Counters::value(docstring const & ctr) const } -void Counters::resetSlaves(docstring const & ctr) +void Counters::resetSlaves(docstring const & count) { - CounterList::iterator it = counterList_.begin(); - CounterList::iterator const end = counterList_.end(); - for (; it != end; ++it) { - if (it->second.master() == ctr) { - it->second.reset(); - resetSlaves(it->first); + for (auto & ctr : counterList_) { + if (ctr.second.master() == count) { + ctr.second.reset(); + resetSlaves(ctr.first); } } } @@ -315,14 +313,12 @@ void Counters::reset() appendix_ = false; subfloat_ = false; current_float_.erase(); - CounterList::iterator it = counterList_.begin(); - CounterList::iterator const end = counterList_.end(); - for (; it != end; ++it) - it->second.reset(); + for (auto & ctr : counterList_) + ctr.second.reset(); counter_stack_.clear(); counter_stack_.push_back(from_ascii("")); layout_stack_.clear(); - layout_stack_.push_back(0); + layout_stack_.push_back(nullptr); } @@ -330,11 +326,9 @@ void Counters::reset(docstring const & match) { LASSERT(!match.empty(), return); - CounterList::iterator it = counterList_.begin(); - CounterList::iterator end = counterList_.end(); - for (; it != end; ++it) { - if (it->first.find(match) != string::npos) - it->second.reset(); + for (auto & ctr : counterList_) { + if (ctr.first.find(match) != string::npos) + ctr.second.reset(); } } @@ -344,12 +338,10 @@ bool Counters::remove(docstring const & cnt) bool retval = counterList_.erase(cnt); if (!retval) return false; - CounterList::iterator it = counterList_.begin(); - CounterList::iterator end = counterList_.end(); - for (; it != end; ++it) { - if (it->second.checkAndRemoveMaster(cnt)) + for (auto & ctr : counterList_) { + if (ctr.second.checkAndRemoveMaster(cnt)) LYXERR(Debug::TCLASS, "Removed master counter `" + - to_utf8(cnt) + "' from counter: " + to_utf8(it->first)); + to_utf8(cnt) + "' from counter: " + to_utf8(ctr.first)); } return retval; } @@ -357,11 +349,9 @@ bool Counters::remove(docstring const & cnt) void Counters::copy(Counters & from, Counters & to, docstring const & match) { - CounterList::iterator it = counterList_.begin(); - CounterList::iterator end = counterList_.end(); - for (; it != end; ++it) { - if (it->first.find(match) != string::npos || match == "") { - to.set(it->first, from.value(it->first)); + for (auto const & ctr : counterList_) { + if (ctr.first.find(match) != string::npos || match == "") { + to.set(ctr.first, from.value(ctr.first)); } } } diff --git a/src/Counters.h b/src/Counters.h index 536dcc17a6..89383bc76a 100644 --- a/src/Counters.h +++ b/src/Counters.h @@ -193,7 +193,7 @@ public: /// Also for updateBuffer(). /// Call this when entering things like footnotes, where there is now /// no "last layout" and we want to restore the "last layout" on exit. - void clearLastLayout() { layout_stack_.push_back(0); } + void clearLastLayout() { layout_stack_.push_back(nullptr); } /// Call this when exiting things like footnotes. void restoreLastLayout() { layout_stack_.pop_back(); } ///