qt6-bb10/tests/auto/corelib/tools
Giuseppe D'Angelo 0deff80eab Associative containers: add a way to obtain a key/value range
Our associative containers' iterator's value_type isn't a destructurable
type (yielding key/value). This means that something like

  for (auto [k, v] : map)

doesn't even compile -- one can only "directly" iterate on the
values. For quite some time we've had QKeyValueIterator to allow
key/value iteration, but then one had to resort to a "traditional" for
loop:

  for (auto i = map.keyValueBegin(), e = keyValueEnd(); i!=e; ++i)

This can be easily packaged in an adaptor class, which is what this
commmit does, thereby offering a C++17-compatible way to obtain
key/value iteration over associative containers.

Something possibly peculiar is the fact that the range so obtained is
a range of pairs of references -- not a range of references to pairs.
But that's easily explained by the fact that we have no pairs to build
references to; hence,

 for (auto &[k, v] : map.asKeyValueRange())

doesn't compile (lvalue reference doesn't bind to prvalue pair).
Instead, both of these compile:

  for (auto [k, v] : map.asKeyValueRange())
  for (auto &&[k, v] : map.asKeyValueRange())

and in *both* cases one gets references to the keys/values in the map.
If the map is non-const, the reference to the value is mutable.

Last but not least, implement pinning for rvalue containers.

[ChangeLog][QtCore][QMap] Added asKeyValueRange().
[ChangeLog][QtCore][QMultiMap] Added asKeyValueRange().
[ChangeLog][QtCore][QHash] Added asKeyValueRange().
[ChangeLog][QtCore][QMultiHash] Added asKeyValueRange().

Task-number: QTBUG-4615
Change-Id: Ic8506bff38b2f753494b21ab76f52e05c06ffc8b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-03-04 00:21:44 +01:00
..
collections Add qt_internal_undefine_global_definition function 2022-02-02 16:45:37 +01:00
containerapisymmetry Associative containers: add a way to obtain a key/value range 2022-03-04 00:21:44 +01:00
qalgorithms Remove the qmake project files 2021-01-07 15:32:28 +01:00
qarraydata Fix signed/unsigned comparison warnings in tst_QArrayData 2021-10-29 14:11:46 +02:00
qbitarray Remove the qmake project files 2021-01-07 15:32:28 +01:00
qcache Fix gcc warning in tests 2022-01-24 12:59:37 +00:00
qcommandlineparser Compile autotests for Integrity 2021-09-20 17:29:04 +03:00
qcontiguouscache Remove the qmake project files 2021-01-07 15:32:28 +01:00
qcryptographichash Cleanup tests that add test data to resources explicitly 2022-02-11 21:54:44 +01:00
qduplicatetracker QDuplicateTracker: add clear() 2021-11-11 13:26:14 -08:00
qeasingcurve Remove the qmake project files 2021-01-07 15:32:28 +01:00
qexplicitlyshareddatapointer Remove the qmake project files 2021-01-07 15:32:28 +01:00
qflatmap QFlatMap: add remove_if 2022-03-03 00:25:14 +01:00
qfreelist CMake: Remove the usage of QT_SOURCE_TREE from tests 2021-07-12 18:56:14 +02:00
qhash Add qt_internal_undefine_global_definition function 2022-02-02 16:45:37 +01:00
qhashfunctions QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH: use unqualified qHash() lookup 2021-11-29 18:55:10 +00:00
qhashseed tst_QHashSeed: improve quality of the quality() test 2021-11-23 20:48:08 -08:00
qline Exclude denormal test cases if system doesn't support it 2022-02-15 00:48:23 +02:00
qlist Fix build with C++20 on macOS 2022-02-11 22:56:35 +01:00
qmacautoreleasepool Remove the qmake project files 2021-01-07 15:32:28 +01:00
qmakearray Remove the qmake project files 2021-01-07 15:32:28 +01:00
qmap Add qt_internal_undefine_global_definition function 2022-02-02 16:45:37 +01:00
qmargins Remove the qmake project files 2021-01-07 15:32:28 +01:00
qmessageauthenticationcode Remove the qmake project files 2021-01-07 15:32:28 +01:00
qoffsetstringarray qlibraryinfo.cpp: use qOffsetStringArray for qtConfEntries 2021-11-03 14:54:37 -07:00
qpair Remove the qmake project files 2021-01-07 15:32:28 +01:00
qpoint Remove the qmake project files 2021-01-07 15:32:28 +01:00
qpointf Remove the qmake project files 2021-01-07 15:32:28 +01:00
qqueue Remove the qmake project files 2021-01-07 15:32:28 +01:00
qrect Remove the qmake project files 2021-01-07 15:32:28 +01:00
qringbuffer Make QRingBuffer a move-only type 2021-12-16 00:01:41 +01:00
qscopedpointer Disable warnings from using deprecated QScopedPointer::take 2021-02-13 06:44:52 +01:00
qscopedvaluerollback Remove the qmake project files 2021-01-07 15:32:28 +01:00
qscopeguard Remove checks for features available in C++17 2021-10-02 17:54:39 +02:00
qset Add qt_internal_undefine_global_definition function 2022-02-02 16:45:37 +01:00
qsharedpointer Long live QVERIFY_THROWS_EXCEPTION! 2021-11-26 04:44:26 +01:00
qsize Add more support for structured bindings 2021-02-25 16:08:44 +01:00
qsizef Add more support for structured bindings 2021-02-25 16:08:44 +01:00
qstl Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtaggedpointer Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtimeline Port of QTimeLine to new property system 2021-04-26 16:44:54 +02:00
qvarlengtharray QVarLengthArray: don't allow syncqt to export base classes 2021-12-15 00:04:45 +01:00
qversionnumber QVersionNumber: port fromString() to QAnyStringView 2022-01-18 01:31:33 +01:00
CMakeLists.txt Activate tst_QTimeLine on Android 2022-02-10 15:14:57 +01:00