mirror of https://github.com/YosysHQ/yosys.git
Rename overloaded `insert()` to `emplace()` and add overloaded versions for all possible lvalue/rvalue combinationsfor its arguments.
This commit is contained in:
parent
c479fdeb85
commit
5eb1f83d2d
|
@ -465,7 +465,17 @@ public:
|
||||||
return std::pair<iterator, bool>(iterator(this, i), true);
|
return std::pair<iterator, bool>(iterator(this, i), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<iterator, bool> insert(K const &key, T &&rvalue)
|
std::pair<iterator, bool> emplace(K const &key, T const &value)
|
||||||
|
{
|
||||||
|
int hash = do_hash(key);
|
||||||
|
int i = do_lookup(key, hash);
|
||||||
|
if (i >= 0)
|
||||||
|
return std::pair<iterator, bool>(iterator(this, i), false);
|
||||||
|
i = do_insert(std::make_pair(key, value), hash);
|
||||||
|
return std::pair<iterator, bool>(iterator(this, i), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<iterator, bool> emplace(K const &key, T &&rvalue)
|
||||||
{
|
{
|
||||||
int hash = do_hash(key);
|
int hash = do_hash(key);
|
||||||
int i = do_lookup(key, hash);
|
int i = do_lookup(key, hash);
|
||||||
|
@ -475,6 +485,26 @@ public:
|
||||||
return std::pair<iterator, bool>(iterator(this, i), true);
|
return std::pair<iterator, bool>(iterator(this, i), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::pair<iterator, bool> emplace(K &&rkey, T const &value)
|
||||||
|
{
|
||||||
|
int hash = do_hash(rkey);
|
||||||
|
int i = do_lookup(rkey, hash);
|
||||||
|
if (i >= 0)
|
||||||
|
return std::pair<iterator, bool>(iterator(this, i), false);
|
||||||
|
i = do_insert(std::make_pair(std::forward<K>(rkey), value), hash);
|
||||||
|
return std::pair<iterator, bool>(iterator(this, i), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<iterator, bool> emplace(K &&rkey, T &&rvalue)
|
||||||
|
{
|
||||||
|
int hash = do_hash(rkey);
|
||||||
|
int i = do_lookup(rkey, hash);
|
||||||
|
if (i >= 0)
|
||||||
|
return std::pair<iterator, bool>(iterator(this, i), false);
|
||||||
|
i = do_insert(std::make_pair(std::forward<K>(rkey), std::forward<T>(rvalue)), hash);
|
||||||
|
return std::pair<iterator, bool>(iterator(this, i), true);
|
||||||
|
}
|
||||||
|
|
||||||
int erase(const K &key)
|
int erase(const K &key)
|
||||||
{
|
{
|
||||||
int hash = do_hash(key);
|
int hash = do_hash(key);
|
||||||
|
|
Loading…
Reference in New Issue