diff options
Diffstat (limited to 'src/corelib/tools/qflatmap_p.h')
-rw-r--r-- | src/corelib/tools/qflatmap_p.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/corelib/tools/qflatmap_p.h b/src/corelib/tools/qflatmap_p.h index 3b847fc63a..fd08676ae3 100644 --- a/src/corelib/tools/qflatmap_p.h +++ b/src/corelib/tools/qflatmap_p.h @@ -750,6 +750,24 @@ public: } } + template <typename M> + std::pair<iterator, bool> insert_or_assign(const Key &key, M &&obj) + { + auto r = try_emplace(key, std::forward<M>(obj)); + if (!r.second) + *toValuesIterator(r.first) = std::forward<M>(obj); + return r; + } + + template <typename M> + std::pair<iterator, bool> insert_or_assign(Key &&key, M &&obj) + { + auto r = try_emplace(std::move(key), std::forward<M>(obj)); + if (!r.second) + *toValuesIterator(r.first) = std::forward<M>(obj); + return r; + } + template <class InputIt, is_compatible_iterator<InputIt> = nullptr> void insert(InputIt first, InputIt last) { |