summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2020-11-26 15:43:17 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2020-12-02 10:17:11 +0100
commit734c8aa9d904e81119b54d4311a2ec7161ee9b90 (patch)
treeb9f106c4cae3479b03fe43822d463fe25c14f127 /src
parent6364194456ec92a2c09a339d20b868bb49bd00e9 (diff)
QSet: add insert(T&&)
We already have all we need in QHash to support this, so the addition is simple enough. Add test checking how many copies and/or moves are needed for a single insert. As a drive-by: remove some unneeded static_cast Change-Id: Iaf768657644afa45f78f5c81ffcf89ba9607be96 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qset.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index 3a51988852..681ce9cbe2 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -184,7 +184,9 @@ public:
typedef const_iterator ConstIterator;
inline qsizetype count() const { return q_hash.count(); }
inline iterator insert(const T &value)
- { return static_cast<typename Hash::iterator>(q_hash.insert(value, QHashDummyValue())); }
+ { return q_hash.insert(value, QHashDummyValue()); }
+ inline iterator insert(T &&value)
+ { return q_hash.emplace(std::move(value), QHashDummyValue()); }
iterator find(const T &value) { return q_hash.find(value); }
const_iterator find(const T &value) const { return q_hash.find(value); }
inline const_iterator constFind(const T &value) const { return find(value); }