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>
This commit is contained in:
Marc Mutz 2017-03-28 15:03:50 +02:00
parent 9349ec2921
commit e7a7931ba1
2 changed files with 16 additions and 0 deletions

View File

@ -773,6 +773,21 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
\sa quintptr, qint32, qint64
*/
/*!
\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>

View File

@ -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