Add literal operator to efficiently construct QString in Qt5

PR #16448.
This commit is contained in:
Chocobo1
2022-02-18 11:28:04 +08:00
committed by GitHub
parent 37e6a9ebc2
commit 852a14992c
2 changed files with 14 additions and 6 deletions

View File

@@ -48,3 +48,11 @@ constexpr typename std::add_const_t<T> asConst(T &&t) noexcept { return std::mov
// Prevent const rvalue arguments
template <typename T>
void asConst(const T &&) = delete;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// https://doc.qt.io/qt-6/qstring.html#operator-22-22_qs
inline QString operator"" _qs(const char16_t *str, const std::size_t size)
{
return QString::fromRawData(reinterpret_cast<const QChar *>(str), size);
}
#endif