summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtest.h
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 /src/testlib/qtest.h
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>
Diffstat (limited to 'src/testlib/qtest.h')
-rw-r--r--src/testlib/qtest.h7
1 files changed, 3 insertions, 4 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)