]> git.lyx.org Git - features.git/commitdiff
Use ranges, fix warning
authorRichard Kimberly Heck <rikiheck@lyx.org>
Fri, 28 Feb 2020 06:48:10 +0000 (01:48 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Fri, 28 Feb 2020 06:48:10 +0000 (01:48 -0500)
src/Counters.cpp
src/Counters.h

index 2daac53224dca0a4f26e6850d3b7d7a228e6c1be..830a1002ca70559c7b901ba47688c379fb8b3cfa 100644 (file)
@@ -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));
                }
        }
 }
index 536dcc17a6a9321b3226e747dbae9c77aed57ac7..89383bc76ab3bc261b33c1a0966ce281908d3a45 100644 (file)
@@ -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(); }
        ///