diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-03-28 15:03:50 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2017-03-29 07:36:33 +0000 |
commit | e7a7931ba1e4fd6d80674c73e6e9e9a8099b9391 (patch) | |
tree | 803b80135b159f28c1b2f684e050c7a9b7189dd1 | |
parent | 9349ec29212a2dc36aa2460626851a16820a41b6 (diff) |
QtGlobal: add qssize_t
It replaces Posix' ssize_t in cross-platform code. Most importantly,
it allows QStringView users to refer to QStringView::size_type by
a shorter, less intimidating name.
Change-Id: I2128fefd2ffdd258b0b55cd90802a23c6bc033f6
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/global/qglobal.cpp | 15 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 871810e5a3..4ff27f14a8 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -774,6 +774,21 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in */ /*! + \typedef qssize_t + \relates <QtGlobal> + \since 5.10 + + Integral type providing Posix' \c ssize_t for all platforms. + + This type is guaranteed to be the same size as a \c size_t on all + platforms supported by Qt. + + Note that qssize_t is signed. Use \c size_t for unsigned values. + + \sa qptrdiff +*/ + +/*! \enum QtMsgType \relates <QtGlobal> diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 12220e10b5..3dfbf2fb2d 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -451,6 +451,7 @@ typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint; typedef QIntegerForSizeof<void*>::Unsigned quintptr; typedef QIntegerForSizeof<void*>::Signed qptrdiff; typedef qptrdiff qintptr; +using qssize_t = QIntegerForSizeof<std::size_t>::Signed; /* moc compats (signals/slots) */ #ifndef QT_MOC_COMPAT |