aboutsummaryrefslogtreecommitdiffstats
path: root/common/util.h
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-06-22 15:38:17 +0200
committerClifford Wolf <clifford@clifford.at>2018-06-22 15:38:17 +0200
commit001c6ceb5661976eb3f0146c1b819a7f2ad8ea7d (patch)
tree06846f1268806265eaaa4d1ec97410e8c0045621 /common/util.h
parent9b98a7175be440a6a59ddcc022615e04b8538bda (diff)
parent56c09fc5e5f7fb5c299f7a0b52e839556146615d (diff)
downloadnextpnr-001c6ceb5661976eb3f0146c1b819a7f2ad8ea7d.tar.gz
nextpnr-001c6ceb5661976eb3f0146c1b819a7f2ad8ea7d.tar.bz2
nextpnr-001c6ceb5661976eb3f0146c1b819a7f2ad8ea7d.zip
Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr
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 34b2ed02..4c60292b 100644
--- a/common/util.h
+++ b/common/util.h
@@ -20,6 +20,7 @@
#ifndef UTIL_H
#define UTIL_H
+#include <map>
#include <string>
#include "nextpnr.h"
@@ -56,6 +57,14 @@ bool bool_or_default(const Container &ct, const KeyType &key, bool def = false)
{
return bool(int_or_default(ct, key, int(def)));
};
+
+// Wrap an unordered_map, and allow it to be iterated over sorted by key
+template <typename K, typename V>
+std::map<K, V> sorted(const std::unordered_map<K, V> &orig)
+{
+ return std::map<K, V>(orig.begin(), orig.end());
+};
+
NEXTPNR_NAMESPACE_END
#endif