From 12b4ce72815fc1ea272da729eeb3713a9d5a4089 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 11 Mar 2020 09:41:56 +0100 Subject: [PATCH] QStringView: adapt to C++20 constexpr std::basic_string Just mark the constructor constexpr. If std::basic_string isn't, then this will be silently dropped. If std::basic_string is, we can now construct QStringView from std::basic_strings at compile-time. [ChangeLog][QtCore][QStringView] Conversion from std::basic_string can now be constexpr (when std::basic_string is). Change-Id: Ia608f1a71c9a24f417b3e21e150ff6bd3d2f4fc4 Reviewed-by: Lars Knoll --- src/corelib/text/qstringview.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h index 83418970a5..a2e55f5b16 100644 --- a/src/corelib/text/qstringview.h +++ b/src/corelib/text/qstringview.h @@ -211,7 +211,7 @@ public: #endif template = true> - QStringView(const StdBasicString &str) noexcept + Q_DECL_CONSTEXPR QStringView(const StdBasicString &str) noexcept : QStringView(str.data(), qsizetype(str.size())) {} Q_REQUIRED_RESULT inline QString toString() const; // defined in qstring.h