QFlatMap: implement mutable op[] via try_emplace()
De-duplicates code. Pick-to: 6.3 Change-Id: Id7841a0717cd66bd56d489e6d2630e9eeb284316 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>bb10
parent
1e07787142
commit
f08f28548a
|
|
@ -651,22 +651,12 @@ public:
|
|||
|
||||
T &operator[](const Key &key)
|
||||
{
|
||||
auto it = lower_bound(key);
|
||||
if (it == end() || key_compare::operator()(key, it.key())) {
|
||||
c.keys.insert(toKeysIterator(it), key);
|
||||
return *c.values.insert(toValuesIterator(it), T());
|
||||
}
|
||||
return it.value();
|
||||
return try_emplace(key).first.value();
|
||||
}
|
||||
|
||||
T &operator[](Key &&key)
|
||||
{
|
||||
auto it = lower_bound(key);
|
||||
if (it == end() || key_compare::operator()(key, it.key())) {
|
||||
c.keys.insert(toKeysIterator(it), key);
|
||||
return *c.values.insert(toValuesIterator(it), T());
|
||||
}
|
||||
return it.value();
|
||||
return try_emplace(std::move(key)).first.value();
|
||||
}
|
||||
|
||||
T operator[](const Key &key) const
|
||||
|
|
|
|||
Loading…
Reference in New Issue