QFlatMap: fix mixed rvalue/lvalue insert overloads
They never worked. Pick-to: 6.3 6.2 Change-Id: I9a15c848416419823f28ea580248fbe93a4365dd Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>bb10
parent
faa26be44c
commit
e6cd1eb079
|
|
@ -702,7 +702,7 @@ public:
|
|||
auto it = lower_bound(key);
|
||||
if (it == end() || key_compare::operator()(key, it.key())) {
|
||||
c.values.insert(toValuesIterator(it), value);
|
||||
return { c.keys.insert(it, std::move(key)), true };
|
||||
return { fromKeysIterator(c.keys.insert(toKeysIterator(it), std::move(key))), true };
|
||||
} else {
|
||||
*toValuesIterator(it) = value;
|
||||
return {it, false};
|
||||
|
|
@ -714,7 +714,7 @@ public:
|
|||
auto it = lower_bound(key);
|
||||
if (it == end() || key_compare::operator()(key, it.key())) {
|
||||
c.values.insert(toValuesIterator(it), std::move(value));
|
||||
return { c.keys.insert(it, key), true };
|
||||
return { fromKeysIterator(c.keys.insert(toKeysIterator(it), key)), true };
|
||||
} else {
|
||||
*toValuesIterator(it) = std::move(value);
|
||||
return {it, false};
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ private slots:
|
|||
void constructing();
|
||||
void constAccess();
|
||||
void insertion();
|
||||
void insertRValuesAndLValues();
|
||||
void removal();
|
||||
void extraction();
|
||||
void iterators();
|
||||
|
|
@ -156,6 +157,42 @@ void tst_QFlatMap::insertion()
|
|||
QCOMPARE(m.value("gnampf").data(), "GNAMPF");
|
||||
}
|
||||
|
||||
void tst_QFlatMap::insertRValuesAndLValues()
|
||||
{
|
||||
using Map = QFlatMap<QByteArray, QByteArray>;
|
||||
const QByteArray foo = QByteArrayLiteral("foo");
|
||||
const QByteArray bar = QByteArrayLiteral("bar");
|
||||
|
||||
auto rvalue = [](const QByteArray &ba) { return ba; };
|
||||
#define lvalue(x) x
|
||||
|
||||
{
|
||||
Map m;
|
||||
QVERIFY( m.insert(lvalue(foo), lvalue(bar)).second);
|
||||
QVERIFY(!m.insert(lvalue(foo), lvalue(bar)).second);
|
||||
}
|
||||
|
||||
{
|
||||
Map m;
|
||||
QVERIFY( m.insert(lvalue(foo), rvalue(bar)).second);
|
||||
QVERIFY(!m.insert(lvalue(foo), rvalue(bar)).second);
|
||||
}
|
||||
|
||||
{
|
||||
Map m;
|
||||
QVERIFY( m.insert(rvalue(foo), lvalue(bar)).second);
|
||||
QVERIFY(!m.insert(rvalue(foo), lvalue(bar)).second);
|
||||
}
|
||||
|
||||
{
|
||||
Map m;
|
||||
QVERIFY( m.insert(rvalue(foo), rvalue(bar)).second);
|
||||
QVERIFY(!m.insert(rvalue(foo), rvalue(bar)).second);
|
||||
}
|
||||
|
||||
#undef lvalue
|
||||
}
|
||||
|
||||
void tst_QFlatMap::extraction()
|
||||
{
|
||||
using Map = QFlatMap<int, QByteArray>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue