diff --git a/src/libs/utils/smallstring.h b/src/libs/utils/smallstring.h index 8c9c10de28c..7167be47992 100644 --- a/src/libs/utils/smallstring.h +++ b/src/libs/utils/smallstring.h @@ -837,6 +837,54 @@ template<> struct hash } }; +template< + class Key, + class T, + class Hash, + class KeyEqual, + class Allocator> +class unordered_map; + +template, + typename KeyEqual = equal_to, + typename Allocator = allocator>> +QDataStream &operator<<(QDataStream &out, const unordered_map &map) +{ + out << quint64(map.size()); + + for (auto &&entry : map) + out << entry.first << entry.second; + + return out; +} + +template, + typename KeyEqual = equal_to, + typename Allocator = allocator>> +QDataStream &operator>>(QDataStream &in, unordered_map &map) +{ + quint64 size; + + in >> size; + + map.reserve(size); + + for (quint64 i = 0; i < size; ++i) { + Key key; + Value value; + + in >> key >> value; + + map.insert(make_pair(move(key), move(value))); + } + + return in; +} + } // namespace std #pragma pop_macro("noexcept")