Revert "QStringView: simplify the constructor from QString"
This reverts commit 7d18ad49a37440835bb38bd77bc4e0991387ada0. Reason for revert: This changes the constructor from being a template to being a normal function, so changes overload resolution. The commit message gave no indication on why this is safe. Since it's just a nice to have, revert instead of running the risk of breaking code. Change-Id: Icd506e7221bb50c99f276f6a43c15403ec0be7a9 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit ff7e5987ecdd09f87cfcdb4c42039214627dcdb6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
244618c19a
commit
9ea3087d36
@ -1486,13 +1486,6 @@ inline QString &&asString(QString &&s) { return std::move(s); }
|
||||
static_cast<const wchar_t*>(static_cast<const void*>(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
|
||||
//
|
||||
|
@ -97,6 +97,9 @@ private:
|
||||
template <typename Pointer>
|
||||
using if_compatible_pointer = typename std::enable_if<QtPrivate::IsCompatiblePointer<Pointer>::value, bool>::type;
|
||||
|
||||
template <typename T>
|
||||
using if_compatible_qstring_like = typename std::enable_if<std::is_same<T, QString>::value, bool>::type;
|
||||
|
||||
template <typename T>
|
||||
using if_compatible_container = typename std::enable_if<QtPrivate::IsContainerCompatibleWithQStringView<T>::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 <typename String, if_compatible_qstring_like<String> = true>
|
||||
QStringView(const String &str) noexcept
|
||||
: QStringView(str.isNull() ? nullptr : str.data(), qsizetype(str.size())) {}
|
||||
#endif
|
||||
|
||||
template <typename Container, if_compatible_container<Container> = true>
|
||||
constexpr Q_ALWAYS_INLINE QStringView(const Container &c) noexcept
|
||||
|
Loading…
x
Reference in New Issue
Block a user