aboutsummaryrefslogtreecommitdiffstats
path: root/common/util.h
diff options
context:
space:
mode:
authorSergiusz Bazanski <q3k@q3k.org>2018-06-22 14:29:28 +0100
committerSergiusz Bazanski <q3k@q3k.org>2018-06-22 14:29:28 +0100
commit858acc5c1c0ee4bbdfb8d2012b80cda656ca39db (patch)
tree7cc94b94e40c05c5a7baae61c9d0db4f23a31b60 /common/util.h
parent98b1f0c041b01d07f64e8e04503f8eccb05a93de (diff)
parentf86a0d6c8c8792c36c87cf345665ce7c9fbcc60f (diff)
downloadnextpnr-858acc5c1c0ee4bbdfb8d2012b80cda656ca39db.tar.gz
nextpnr-858acc5c1c0ee4bbdfb8d2012b80cda656ca39db.tar.bz2
nextpnr-858acc5c1c0ee4bbdfb8d2012b80cda656ca39db.zip
Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr into q3k/gl
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