diff options
Diffstat (limited to 'common/util.h')
-rw-r--r-- | common/util.h | 9 |
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 |