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
parent
0ae6803d39
commit
12b4ce7281
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue