about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-17T17·24+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-17T18·13+0200
commit6bd2c7bb386de16310fa5534275e6e638be60862 (patch)
tree0a12144dfb4e8d1b069bc09d583b522b5c158b28 /src/libutil
parent1511aa9f488ba0762c2da0bf8ab61b5fde47305d (diff)
OCD: foreach -> C++11 ranged for
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/serialise.cc4
-rw-r--r--src/libutil/util.cc8
-rw-r--r--src/libutil/util.hh7
-rw-r--r--src/libutil/xml-writer.cc8
4 files changed, 10 insertions, 17 deletions
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc
index aa16a20e6d35..789227102864 100644
--- a/src/libutil/serialise.cc
+++ b/src/libutil/serialise.cc
@@ -200,8 +200,8 @@ Sink & operator << (Sink & out, const string & s)
 template<class T> void writeStrings(const T & ss, Sink & sink)
 {
     writeInt(ss.size(), sink);
-    foreach (typename T::const_iterator, i, ss)
-        writeString(*i, sink);
+    for (auto & i : ss)
+        writeString(i, sink);
 }
 
 template void writeStrings(const Paths & ss, Sink & sink);
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 596b79e10e69..f54fd5fb623f 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -1060,9 +1060,9 @@ template vector<string> tokenizeString(const string & s, const string & separato
 string concatStringsSep(const string & sep, const Strings & ss)
 {
     string s;
-    foreach (Strings::const_iterator, i, ss) {
+    for (auto & i : ss) {
         if (s.size() != 0) s += sep;
-        s += *i;
+        s += i;
     }
     return s;
 }
@@ -1071,9 +1071,9 @@ string concatStringsSep(const string & sep, const Strings & ss)
 string concatStringsSep(const string & sep, const StringSet & ss)
 {
     string s;
-    foreach (StringSet::const_iterator, i, ss) {
+    for (auto & i : ss) {
         if (s.size() != 0) s += sep;
-        s += *i;
+        s += i;
     }
     return s;
 }
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 187e05ece050..980cdf4cb774 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -15,13 +15,6 @@
 namespace nix {
 
 
-#define foreach(it_type, it, collection)                                \
-    for (it_type it = (collection).begin(); it != (collection).end(); ++it)
-
-#define foreach_reverse(it_type, it, collection)                                \
-    for (it_type it = (collection).rbegin(); it != (collection).rend(); ++it)
-
-
 /* Return an environment variable. */
 string getEnv(const string & key, const string & def = "");
 
diff --git a/src/libutil/xml-writer.cc b/src/libutil/xml-writer.cc
index 01794001b2c6..98bd058d18be 100644
--- a/src/libutil/xml-writer.cc
+++ b/src/libutil/xml-writer.cc
@@ -73,10 +73,10 @@ void XMLWriter::writeEmptyElement(const string & name,
 
 void XMLWriter::writeAttrs(const XMLAttrs & attrs)
 {
-    for (XMLAttrs::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
-        output << " " << i->first << "=\"";
-        for (unsigned int j = 0; j < i->second.size(); ++j) {
-            char c = i->second[j];
+    for (auto & i : attrs) {
+        output << " " << i.first << "=\"";
+        for (unsigned int j = 0; j < i.second.size(); ++j) {
+            char c = i.second[j];
             if (c == '"') output << "&quot;";
             else if (c == '<') output << "&lt;";
             else if (c == '>') output << "&gt;";