diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 3e28d7727c2..c2628c6f7d3 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -1486,13 +1486,6 @@ inline QString &&asString(QString &&s) { return std::move(s); } static_cast(static_cast(QtPrivate::asString(string).utf16())) #endif -// -// QStringView::QStringView(const QString &) implementation -// - -inline QStringView::QStringView(const QString &str) noexcept - : QStringView(str.isNull() ? nullptr : str.data(), qsizetype(str.size())) {} - // // QStringView::arg() implementation // diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h index e91bb6978c6..d9a4d4ba652 100644 --- a/src/corelib/text/qstringview.h +++ b/src/corelib/text/qstringview.h @@ -97,6 +97,9 @@ private: template using if_compatible_pointer = typename std::enable_if::value, bool>::type; + template + using if_compatible_qstring_like = typename std::enable_if::value, bool>::type; + template using if_compatible_container = typename std::enable_if::value, bool>::type; @@ -151,7 +154,13 @@ public: : QStringView(str, str ? lengthHelperPointer(str) : 0) {} #endif - inline QStringView(const QString &str) noexcept; +#ifdef Q_QDOC + QStringView(const QString &str) noexcept; +#else + template = true> + QStringView(const String &str) noexcept + : QStringView(str.isNull() ? nullptr : str.data(), qsizetype(str.size())) {} +#endif template = true> constexpr Q_ALWAYS_INLINE QStringView(const Container &c) noexcept