Bring back QASV::detects_US_ASCII_at_compile_time

Even though undocumented, it's public API, doesn't hurt to carry
along, and improves compiler coverage in the test, so let's not remove
it.

Found in 6.7 API review

Amends 95e6fac0a5.

Pick-to: 6.7
Change-Id: Ia935036a69e0e678f22ac86b48a2c1c5e8c46733
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
bb10
Ivan Solovev 2024-02-27 14:28:32 +01:00
parent 60aeeb0e92
commit 380c01bac5
2 changed files with 11 additions and 5 deletions

View File

@ -275,6 +275,14 @@ public:
[[nodiscard]] Q_CORE_EXPORT static int compare(QAnyStringView lhs, QAnyStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT static bool equal(QAnyStringView lhs, QAnyStringView rhs) noexcept;
static constexpr inline bool detects_US_ASCII_at_compile_time =
#ifdef QT_SUPPORTS_IS_CONSTANT_EVALUATED
true
#else
false
#endif
;
//
// STL compatibility API:
//

View File

@ -570,8 +570,7 @@ void tst_QAnyStringView::debug() const
void tst_QAnyStringView::asciiLiteralIsLatin1() const
{
#ifdef QT_SUPPORTS_IS_CONSTANT_EVALUATED
if constexpr (true) {
if constexpr (QAnyStringView::detects_US_ASCII_at_compile_time) {
constexpr bool asciiCstringIsLatin1 = QAnyStringView("Hello, World").isLatin1();
QVERIFY(asciiCstringIsLatin1);
constexpr bool asciiUtf8stringIsLatin1 = QAnyStringView(u8"Hello, World").isLatin1();
@ -587,10 +586,9 @@ void tst_QAnyStringView::asciiLiteralIsLatin1() const
constexpr bool utf8StringArrayIsNotLatin1 =
!QAnyStringView::fromArray(u8"Tørrfisk").isLatin1();
QVERIFY(utf8StringArrayIsNotLatin1);
} else {
QSKIP("Compile-detection of US-ASCII strings not possible with this compiler");
}
#else
QSKIP("Compile-detection of US-ASCII strings not possible with this compiler");
#endif
}
template <typename StringBuilder>