Add util::hash_map::operator[]

This commit is contained in:
Nikita Lisitsa 2024-02-28 16:59:58 +03:00
parent d1104f9aac
commit 4ff36a61ba

View file

@ -475,6 +475,14 @@ namespace psemek::util
return impl_.insert(std::move(value));
}
template <typename Key1>
Value & operator[] (Key1 const & key)
{
if (auto it = find(key); it != end())
return it->second;
return insert({Key(key), Value{}}).first->second;
}
template <typename Key1>
iterator find(Key1 const & key) const
{