summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qflatmap_p.h37
1 files changed, 4 insertions, 33 deletions
diff --git a/src/corelib/tools/qflatmap_p.h b/src/corelib/tools/qflatmap_p.h
index fd08676ae3..4c35e0c3ae 100644
--- a/src/corelib/tools/qflatmap_p.h
+++ b/src/corelib/tools/qflatmap_p.h
@@ -679,51 +679,22 @@ public:
std::pair<iterator, bool> insert(const Key &key, const T &value)
{
- auto it = lower_bound(key);
- if (it == end() || key_compare::operator()(key, it.key())) {
- c.values.insert(toValuesIterator(it), value);
- auto k = c.keys.insert(toKeysIterator(it), key);
- return { fromKeysIterator(k), true };
- } else {
- it.value() = value;
- return {it, false};
- }
+ return insert_or_assign(key, value);
}
std::pair<iterator, bool> insert(Key &&key, const T &value)
{
- auto it = lower_bound(key);
- if (it == end() || key_compare::operator()(key, it.key())) {
- c.values.insert(toValuesIterator(it), value);
- return { fromKeysIterator(c.keys.insert(toKeysIterator(it), std::move(key))), true };
- } else {
- *toValuesIterator(it) = value;
- return {it, false};
- }
+ return insert_or_assign(std::move(key), value);
}
std::pair<iterator, bool> insert(const Key &key, T &&value)
{
- auto it = lower_bound(key);
- if (it == end() || key_compare::operator()(key, it.key())) {
- c.values.insert(toValuesIterator(it), std::move(value));
- return { fromKeysIterator(c.keys.insert(toKeysIterator(it), key)), true };
- } else {
- *toValuesIterator(it) = std::move(value);
- return {it, false};
- }
+ return insert_or_assign(key, std::move(value));
}
std::pair<iterator, bool> insert(Key &&key, T &&value)
{
- auto it = lower_bound(key);
- if (it == end() || key_compare::operator()(key, it.key())) {
- c.values.insert(toValuesIterator(it), std::move(value));
- return { fromKeysIterator(c.keys.insert(toKeysIterator(it), std::move(key))), true };
- } else {
- *toValuesIterator(it) = std::move(value);
- return {it, false};
- }
+ return insert_or_assign(std::move(key), std::move(value));
}
template <typename...Args>