diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-03-14 11:07:54 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2017-03-17 01:14:54 +0000 |
commit | 208c71768cca1dda9ea42f3a395889a85810005e (patch) | |
tree | a30ba9232363c845b24ac47206fc2106074feed4 /src/corelib/tools | |
parent | 4351c2af45768bcb68b5bb996c1fb6e24dc9556b (diff) |
QChar: add (char16_t) and (wchar_t) ctors
... for better std C++ integration.
[ChangeLog][QtCore][QChar] Added constructors from char16_t and, on
Windows, wchar_t.
Change-Id: I2d18ea3a37e869b8ea9f4036d7200d9d13c7d929
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qchar.cpp | 18 | ||||
-rw-r--r-- | src/corelib/tools/qchar.h | 7 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 5d5ea4c8a1..db440390c1 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -608,6 +608,24 @@ QT_BEGIN_NAMESPACE */ /*! + \fn QChar::QChar(char16_t ch) + \since 5.10 + + Constructs a QChar corresponding to the UTF-16 character \a ch. + + \note This constructor is not available on MSVC 2013. +*/ + +/*! + \fn QChar::QChar(wchar_t ch) + \since 5.10 + + Constructs a QChar corresponding to the wide character \a ch. + + \note This constructor is only available on Windows. +*/ + +/*! \fn QChar::QChar(char ch) Constructs a QChar corresponding to ASCII/Latin-1 character \a ch. diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index a83e5e6f98..8509e2e182 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -86,6 +86,13 @@ public: Q_DECL_CONSTEXPR QChar(int rc) Q_DECL_NOTHROW : ucs(ushort(rc & 0xffff)) {} Q_DECL_CONSTEXPR QChar(SpecialCharacter s) Q_DECL_NOTHROW : ucs(ushort(s)) {} // implicit Q_DECL_CONSTEXPR QChar(QLatin1Char ch) Q_DECL_NOTHROW : ucs(ch.unicode()) {} // implicit +#if !defined(Q_OS_WIN) || defined(Q_COMPILER_UNICODE_STRINGS) + Q_DECL_CONSTEXPR QChar(char16_t ch) Q_DECL_NOTHROW : ucs(ushort(ch)) {} // implicit +#endif +#if defined(Q_OS_WIN) + Q_STATIC_ASSERT(sizeof(wchar_t) == sizeof(ushort)); + Q_DECL_CONSTEXPR QChar(wchar_t ch) Q_DECL_NOTHROW : ucs(ushort(ch)) {} // implicit +#endif #ifndef QT_NO_CAST_FROM_ASCII QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(char c) Q_DECL_NOTHROW : ucs(uchar(c)) { } |