From a21f99292567418c620ccf2ffbb13946cac03b8d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 7 Jul 2011 19:53:35 +0200 Subject: Add support for QStringLiterals in QStringBuilder Otherwise we get errors for failing to have operator+ properly when writing: QStringLiteral("foo") + s Change-Id: I03844c95e9fdfa886eadfa2b5fe104ff048fd618 Reviewed-on: http://codereview.qt.nokia.com/1351 Reviewed-by: Qt Sanity Bot Reviewed-by: Lars Knoll --- src/corelib/tools/qstringbuilder.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index c86a51f8e3..6d998b62aa 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -249,6 +249,23 @@ template <> struct QConcatenable : private QAbstractConcatenable #endif }; +template struct QConcatenable > : private QAbstractConcatenable +{ + typedef QConstStringDataPtr type; + typedef QString ConvertTo; + enum { ExactSize = true }; + static int size(const type &) { return N; } + static inline void appendTo(const type &a, QChar *&out) + { + memcpy(out, reinterpret_cast(a.ptr->data), sizeof(QChar) * N); + out += N; + } +#ifndef QT_NO_CAST_TO_ASCII + static inline QT_ASCII_CAST_WARN void appendTo(const type &a, char *&out) + { convertToAscii(a.ptr->data, N, out); } +#endif +}; + template <> struct QConcatenable : private QAbstractConcatenable { typedef QStringRef type; -- cgit v1.2.3