QStringView: simplify the constructor from QString
We have to single QString out because of the isNull/isEmpty distinction. Still, we can avoid having a constructor template on it constrained on the argument being precisely QString. This is a historic remnant; in Qt 5 the constructor also worked with QStringRef. Change-Id: I5457a83d5b77887f57ea9910a826f729ec276d28 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
2c6b7ff501
commit
7d18ad49a3
@ -1436,6 +1436,13 @@ 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
|
||||
//
|
||||
|
@ -96,9 +96,6 @@ 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;
|
||||
|
||||
@ -155,13 +152,7 @@ public:
|
||||
: QStringView(str, str ? lengthHelperPointer(str) : 0) {}
|
||||
#endif
|
||||
|
||||
#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
|
||||
inline QStringView(const QString &str) noexcept;
|
||||
|
||||
template <typename Container, if_compatible_container<Container> = true>
|
||||
constexpr Q_ALWAYS_INLINE QStringView(const Container &c) noexcept
|
||||
|
Loading…
Reference in New Issue
Block a user