tst_manualqdatastream: fix gcc error

GCC has a bug [1] that does not allow to specialize templates
outside of a namespace.
An attempt to build the test results in the following error:

 tst_manualqdatastream.cpp:18:15: error: explicit specialization in
 non-namespace scope ‘class tst_QDataStream’

Fix it by converting the template specializations into simple function
overloads.

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282

Change-Id: I7803cce1687ca8ae992f1a57394346eb6fc90c8b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit b9c8c57e3f8f2a07c22059d9c8e7210469198200)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ivan Solovev 2024-01-25 13:31:45 +01:00 committed by Qt Cherry-pick Bot
parent 6e58122cca
commit 06eac4ebc8

View File

@ -15,11 +15,9 @@ class tst_QDataStream : public QObject
template <class T>
void fill(T &input);
template <>
void fill(QSet<qsizetype> &input);
template <>
void fill(QMap<qsizetype, qsizetype> &input);
template <>
void fill(QHash<qsizetype, qsizetype> &input);
template <class T>
@ -58,7 +56,6 @@ void tst_QDataStream::fill(T &input)
qDebug("Created dataset in %lld ms", timer.elapsed());
}
template <>
void tst_QDataStream::fill(QSet<qsizetype> &input)
{
constexpr qsizetype GiB = 1024 * 1024 * 1024;
@ -76,7 +73,6 @@ void tst_QDataStream::fill(QSet<qsizetype> &input)
qDebug("Created dataset in %lld ms", timer.elapsed());
}
template <>
void tst_QDataStream::fill(QMap<qsizetype, qsizetype> &input)
{
constexpr qsizetype GiB = 1024 * 1024 * 1024;
@ -93,7 +89,6 @@ void tst_QDataStream::fill(QMap<qsizetype, qsizetype> &input)
qDebug("Created dataset in %lld ms", timer.elapsed());
}
template <>
void tst_QDataStream::fill(QHash<qsizetype, qsizetype> &input)
{
constexpr qsizetype GiB = 1024 * 1024 * 1024;