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 <lars.knoll@qt.io>
bb10
Marc Mutz 2020-03-11 09:41:56 +01:00
parent 0ae6803d39
commit 12b4ce7281
1 changed files with 1 additions and 1 deletions

View File

@ -211,7 +211,7 @@ public:
#endif
template <typename StdBasicString, if_compatible_string<StdBasicString> = 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