diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-03-30 19:49:32 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2017-04-20 06:50:36 +0000 |
commit | 126c4eae84fee0e5bc4e9c6db167d92e87b7f612 (patch) | |
tree | 330dbd270045bc11f5b36208ae4b027bfe8ceb32 /src | |
parent | 3dcc075f4a5efce348a6fa00cf5a0adef97b1089 (diff) |
Split Q_COMPILER_UNICODE_STRINGS: add Q_STDLIB_UNICODE_STRINGS
Since commit bf2160e72cd8840a8e604438cbdc807483ac980a, we can rely on
charNN_t support in all compilers except MSVC 2013, and since that
commit, we use (in 5.10, not 5.9, yet)
!defined(Q_OS_WIN) || defined(Q_COMPILER_UNICODE_STRINGS)
when we only need charNN_t, the type, as opposed to its library
support (u16string, char_traits<char16_t>, ...).
This patch splits the Q_C_UNICODE_STRINGS macro into two, adding
Q_STDLIB_UNICODE_STRINGS for when we need std::uNNstring, leaving
Q_C_UNICODE_STRINGS for when we need just charNN_t support.
In QDebug, when constructing a QChar out of a char16_t, cast to ushort
first, since QChar(char16_t) was only officially introduced in Qt 5.10.
[ChangeLog][Potentially Source-Incompatible Changes] The internal
Q_COMPILER_UNICODE_STRINGS macro is now defined if the compiler
supports charNN_t, even if the standard library does not. To check for
availability of std::uNNstring, use the new Q_STDLIB_UNICODE_STRINGS
macro.
Change-Id: I8f210fd7f1799fe21faf54506475a759b1f76a59
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 7 | ||||
-rw-r--r-- | src/corelib/io/qdebug.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstring.h | 4 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 5497b9e14a..5fc7ac9c7e 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -994,6 +994,10 @@ # endif /* __cplusplus */ #endif /* Q_CC_MSVC */ +#ifdef Q_COMPILER_UNICODE_STRINGS +# define Q_STDLIB_UNICODE_STRINGS +#endif + #ifdef __cplusplus # include <utility> # if defined(Q_OS_QNX) @@ -1016,8 +1020,9 @@ # undef Q_COMPILER_INITIALIZER_LISTS # undef Q_COMPILER_RVALUE_REFS # undef Q_COMPILER_REF_QUALIFIERS -# undef Q_COMPILER_UNICODE_STRINGS # undef Q_COMPILER_NOEXCEPT +// Disable C++11 library features: +# undef Q_STDLIB_UNICODE_STRINGS # endif // !_HAS_CPP0X # if !defined(_HAS_NULLPTR_T) || !_HAS_NULLPTR_T # undef Q_COMPILER_NULLPTR diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 61059dd694..186722b69b 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -139,7 +139,7 @@ public: inline QDebug &operator<<(signed short t) { stream->ts << t; return maybeSpace(); } inline QDebug &operator<<(unsigned short t) { stream->ts << t; return maybeSpace(); } #ifdef Q_COMPILER_UNICODE_STRINGS - inline QDebug &operator<<(char16_t t) { return *this << QChar(t); } + inline QDebug &operator<<(char16_t t) { return *this << QChar(ushort(t)); } inline QDebug &operator<<(char32_t t) { putUcs4(t); return maybeSpace(); } #endif inline QDebug &operator<<(signed int t) { stream->ts << t; return maybeSpace(); } diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index f81a58813d..109b68c544 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -756,7 +756,7 @@ public: static inline QString fromStdWString(const std::wstring &s); inline std::wstring toStdWString() const; -#if defined(Q_COMPILER_UNICODE_STRINGS) || defined(Q_QDOC) +#if defined(Q_STDLIB_UNICODE_STRINGS) || defined(Q_QDOC) static inline QString fromStdU16String(const std::u16string &s); inline std::u16string toStdU16String() const; static inline QString fromStdU32String(const std::u32string &s); @@ -1339,7 +1339,7 @@ inline std::wstring QString::toStdWString() const inline QString QString::fromStdWString(const std::wstring &s) { return fromWCharArray(s.data(), int(s.size())); } -#if defined(Q_COMPILER_UNICODE_STRINGS) +#if defined(Q_STDLIB_UNICODE_STRINGS) inline QString QString::fromStdU16String(const std::u16string &s) { return fromUtf16(s.data(), int(s.size())); } |