From d631c31235dc3ab682ba5d4cbb466680d47b36f2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 20 Oct 2011 12:47:04 +0200 Subject: Make QStringLiteral and QByteArrayLiteral always return the real types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Up until now, the macros would return an internal type that contained the pointer to the data. This breaks code that tried to use the macros with operators, like QStringBuilder but also when writing: QStringList() << QStringLiteral("a") << QStringLiteral("b"); This change seems to work fine now and I can also verify that this works: const auto str = QStringLiteral("Hello"); Even though it creates a QString, which is non-POD and non-constexpr. Change-Id: Iaf82af9bea4245513a1128ea54f9d2d3d785fb09 Reviewed-by: Olivier Goffart Reviewed-by: Jędrzej Nowacki --- .../qstringbuilder1/stringbuilder.cpp | 30 ---------------------- 1 file changed, 30 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp index 862789cc73..556b9ac16a 100644 --- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp @@ -107,21 +107,6 @@ void runScenario() QCOMPARE(r, r3); #endif - { - static const QStaticStringData<12> literalData = { - Q_STATIC_STRING_DATA_HEADER_INITIALIZER(12), - { 's', 'o', 'm', 'e', ' ', 'l', 'i', 't', 'e', 'r', 'a', 'l' } - }; - static QStringDataPtr literal = { literalData.data_ptr() }; - - r = literal; - QCOMPARE(r, string); - r = r Q literal; - QCOMPARE(r, r2); - r = literal Q literal; - QCOMPARE(r, r2); - } - #ifndef QT_NO_CAST_FROM_ASCII r = string P LITERAL; QCOMPARE(r, r2); @@ -226,21 +211,6 @@ void runScenario() QCOMPARE(r, ba); } - { - static const QStaticByteArrayData<12> literalData = { - Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER(12), - { 's', 'o', 'm', 'e', ' ', 'l', 'i', 't', 'e', 'r', 'a', 'l' } - }; - static QByteArrayDataPtr literal = { literalData.data_ptr() }; - - QByteArray ba = literal; - QCOMPARE(ba, QByteArray(LITERAL)); - ba = ba Q literal; - QCOMPARE(ba, QByteArray(LITERAL LITERAL)); - ba = literal Q literal; - QCOMPARE(ba, QByteArray(LITERAL LITERAL)); - } - //operator QString += { QString str = QString::fromUtf8(UTF8_LITERAL); -- cgit v1.2.3