QSet: add missing insert-with-hint
Since QHash is missing the overload, too, just ignore the hint for now, but provide the STL-compatible signature so generic code can use QSet as a normal sequential container. [ChangeLog][QtCore][QSet] Added insert() overload taking an insertion hint, for STL compatibility. Change-Id: I9fe41877343ebff721b650fb7b9cd4e06b6608d8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
This commit is contained in:
parent
61436f24cb
commit
3f8896d77e
@ -198,6 +198,9 @@ public:
|
||||
typedef qsizetype size_type;
|
||||
|
||||
inline bool empty() const { return isEmpty(); }
|
||||
|
||||
iterator insert(const_iterator, const T &value) { return insert(value); }
|
||||
|
||||
// comfort
|
||||
inline QSet<T> &operator<<(const T &value) { insert(value); return *this; }
|
||||
inline QSet<T> &operator|=(const QSet<T> &other) { unite(other); return *this; }
|
||||
|
@ -507,6 +507,22 @@
|
||||
for STL compatibility. It is equivalent to isEmpty().
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QSet::insert(const_iterator it, const T &value)
|
||||
\overload
|
||||
\since 6.1
|
||||
|
||||
Inserts item \a value into the set, if \a value isn't already
|
||||
in the set, and returns an iterator pointing at the inserted
|
||||
item.
|
||||
|
||||
The iterator \a it is ignored.
|
||||
|
||||
This function is provided for compatibility with the STL.
|
||||
|
||||
\sa operator<<(), remove(), contains()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn template <class T> bool QSet<T>::count() const
|
||||
|
||||
|
@ -143,7 +143,7 @@ static_assert(!QContainerInfo::can_set_value_at_iterator_v<std::set<int>>);
|
||||
static_assert(QContainerInfo::can_set_value_at_iterator_v<std::forward_list<int>>);
|
||||
|
||||
static_assert(QContainerInfo::can_insert_value_at_iterator_v<QVector<int>>);
|
||||
static_assert(!QContainerInfo::can_insert_value_at_iterator_v<QSet<int>>);
|
||||
static_assert(QContainerInfo::can_insert_value_at_iterator_v<QSet<int>>);
|
||||
static_assert(!QContainerInfo::can_insert_value_at_iterator_v<NotAContainer>);
|
||||
static_assert(QContainerInfo::can_insert_value_at_iterator_v<std::vector<int>>);
|
||||
static_assert(!QContainerInfo::can_insert_value_at_iterator_v<std::forward_list<int>>);
|
||||
@ -267,7 +267,7 @@ void tst_QMetaContainer::testSequence_data()
|
||||
<< static_cast<void *>(&qset)
|
||||
<< QMetaSequence::fromContainer<QSet<QByteArray>>()
|
||||
<< QMetaType::fromType<QByteArray>()
|
||||
<< true << false << false << false << false << false << true << false;
|
||||
<< true << false << false << false << false << true << true << false;
|
||||
QTest::addRow("std::set")
|
||||
<< static_cast<void *>(&stdset)
|
||||
<< QMetaSequence::fromContainer<std::set<int>>()
|
||||
|
Loading…
x
Reference in New Issue
Block a user