Add util::hash_map::operator[]
This commit is contained in:
parent
d1104f9aac
commit
4ff36a61ba
1 changed files with 8 additions and 0 deletions
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue