diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-02-26 12:50:31 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-06-25 06:20:18 +0200 |
commit | 95e84c0ea95d3d3b7556c5c12bb2a52f856675d5 (patch) | |
tree | 5f0bbb285e8683240d6131070b5ee6ac1830979f /tests/auto/corelib/text | |
parent | 0dbd2dd86389c0705dbe9f518aed12f609ed09a1 (diff) |
Allow qMin, qMax and qBound for types that can be losslessly converted
Add overloads for qMin and friends where the arguments are of different
type, but one can be easily promoted to the other. Return the promoted
type. Promotions are only allowed if both types are either signed,
unsigned or floating point numbers.
This should simplify writing code in many case (as for example
qMin(myint64, 1)) and also help reduce source incompatibilities between
Qt 5 and Qt 6, where the return types for sizes of our containers changes
from int to qsizetype.
Change-Id: Ia6bcf16bef0469ea568063e7c32f532da610d1cd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/text')
4 files changed, 4 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp index fcf004b4fc..1437717201 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp @@ -26,6 +26,7 @@ ** ****************************************************************************/ +#include <QtCore/qglobal.h> // SCENARIO 1 // this is the "no harm done" version. Only operator% is active, diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp index ac4e383649..8b6350a65d 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp @@ -26,6 +26,7 @@ ** ****************************************************************************/ +#include <QtCore/qglobal.h> // SCENARIO 2 // this is the "full" version. Operator+ is replaced by a QStringBuilder diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp index 6559168cbd..6c5994f7b3 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp @@ -26,6 +26,7 @@ ** ****************************************************************************/ +#include <QtCore/qglobal.h> // SCENARIO 3 // this is the "no harm done" version. Only operator% is active, diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp index 4efc69908e..2aecdcfff6 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp @@ -26,6 +26,7 @@ ** ****************************************************************************/ +#include <QtCore/qglobal.h> // SCENARIO 4 // this is the "full" version. Operator+ is replaced by a QStringBuilder |