QFlatMap: add an alias for using QVarLengthArrays

... in an attempt to foster the use of this data structure by making
it less onerous to spell.

Pick-to: 6.3 6.2
Change-Id: Ib9d17029c75278edde6ba90f65f68af179a6d230
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Marc Mutz 2022-01-09 10:15:21 +01:00
parent 234e0eadc8
commit d4611ba3a5
2 changed files with 4 additions and 2 deletions

View File

@ -993,6 +993,9 @@ private:
containers c;
};
template<class Key, class T, qsizetype N = 256, class Compare = std::less<Key>>
using QVarLengthFlatMap = QFlatMap<Key, T, Compare, QVarLengthArray<Key, N>, QVarLengthArray<T, N>>;
QT_END_NAMESPACE
#endif // QFLATMAP_P_H

View File

@ -558,8 +558,7 @@ void tst_QFlatMap::viewIterators()
void tst_QFlatMap::varLengthArray()
{
using Map = QFlatMap<int, QByteArray, std::less<int>,
QVarLengthArray<int, 1024>, QVarLengthArray<QByteArray, 1024>>;
using Map = QVarLengthFlatMap<int, QByteArray, 1024>;
Map m{ { 2, "twee" } };
m.insert(1, "een");
m.remove(1);