aboutsummaryrefslogtreecommitdiffstats
path: root/common/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/util.h')
-rw-r--r--common/util.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h
index d82e984a..07ebac75 100644
--- a/common/util.h
+++ b/common/util.h
@@ -121,6 +121,15 @@ template <typename K, typename V> std::map<K, V &> sorted_ref(std::unordered_map
return retVal;
};
+// Wrap an unordered_map, and allow it to be iterated over sorted by key
+template <typename K, typename V> std::map<K, const V &> sorted_cref(const std::unordered_map<K, V> &orig)
+{
+ std::map<K, const V &> retVal;
+ for (auto &item : orig)
+ retVal.emplace(std::make_pair(item.first, std::ref(item.second)));
+ return retVal;
+};
+
// Wrap an unordered_set, and allow it to be iterated over sorted by key
template <typename K> std::set<K> sorted(const std::unordered_set<K> &orig)
{