summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-11-29 08:09:57 +0100
committerMarc Mutz <marc.mutz@qt.io>2023-12-06 10:46:54 +0100
commitba44a714067468684ffabe0c9f37bf1cb0785c3c (patch)
tree18e5f01f88d9ac8251ad950646890b23cea3f8b5
parentd42b901ae4f0aa618ca66009ea79d72720b37380 (diff)
QTest: simplify toString(tuple)
Use C++14's std::index_sequence instead of our home-brewed QtPrivate::IndexList. I used make_index_sequence<sizeof...(Types)> instead of index_sequence_for<Types...> to avoid having to resolve another type-dependent template alias. Remove the helper's vacuous \internal qdoc block. As a drive-by, rename the helper function to prevent it from participating in QTest::toString() overload resolution, and fix spaces around &. Pick-to: 6.6 6.5 Change-Id: I5981a9b1a99fbe741e75820a6954d066ced9573d Reviewed-by: Jason McDonald <macadder1@gmail.com>
-rw-r--r--src/testlib/qtest.h7
-rw-r--r--src/testlib/qtestcase.qdoc6
2 files changed, 3 insertions, 10 deletions
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index b3f68a5c8b..99eae8553f 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -377,8 +377,8 @@ inline char *toString(const std::pair<T1, T2> &pair)
return formatString("std::pair(", ")", 2, first.data(), second.data());
}
-template <typename Tuple, int... I>
-inline char *toString(const Tuple & tuple, QtPrivate::IndexesList<I...>) {
+template <typename Tuple, std::size_t... I>
+inline char *tupleToString(const Tuple &tuple, std::index_sequence<I...>) {
using UP = std::unique_ptr<char[]>;
// Generate a table of N + 1 elements where N is the number of
// elements in the tuple.
@@ -392,8 +392,7 @@ inline char *toString(const Tuple & tuple, QtPrivate::IndexesList<I...>) {
template <class... Types>
inline char *toString(const std::tuple<Types...> &tuple)
{
- static const std::size_t params_count = sizeof...(Types);
- return toString(tuple, typename QtPrivate::Indexes<params_count>::Value());
+ return tupleToString(tuple, std::make_index_sequence<sizeof...(Types)>{});
}
inline char *toString(std::nullptr_t)
diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc
index f692b98491..5776177cf6 100644
--- a/src/testlib/qtestcase.qdoc
+++ b/src/testlib/qtestcase.qdoc
@@ -1623,12 +1623,6 @@
*/
/*!
- \fn template <typename Tuple, int... I> char *QTest::toString(const Tuple &tuple, QtPrivate::IndexesList<I...> )
- \internal
- \since 5.12
-*/
-
-/*!
\fn QPointingDevice * QTest::createTouchDevice(QInputDevice::DeviceType devType = QInputDevice::DeviceType::TouchScreen, QInputDevice::Capabilities caps = QInputDevice::Capability::Position)
\since 5.8