From 95c7f88132646489bc17b8ea32facd76a19e19fa Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 7 Dec 2023 20:10:50 +0100 Subject: QArrayData/Pointer: s/QPair/std::pair/ Also port from qMakePair to just braced initialization and CTAD. Task-number: QTBUG-115841 Pick-to: 6.7 Change-Id: Ifd7220ae88b101351e91d1488ce18715eb4880e5 Reviewed-by: Ahmad Samir Reviewed-by: Fabian Kosmale --- src/corelib/tools/qarraydata.cpp | 6 +++--- src/corelib/tools/qarraydata.h | 12 ++++++------ src/corelib/tools/qarraydatapointer.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 3f417fc390..6aebd4306a 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -222,7 +222,7 @@ void *QArrayData::allocate2(QArrayData **dptr, qsizetype capacity, AllocationOpt return r.data; } -QPair +std::pair QArrayData::reallocateUnaligned(QArrayData *data, void *dataPointer, qsizetype objectSize, qsizetype capacity, AllocationOption option) noexcept { @@ -233,7 +233,7 @@ QArrayData::reallocateUnaligned(QArrayData *data, void *dataPointer, qsizetype allocSize = r.size; capacity = r.elementCount; if (Q_UNLIKELY(allocSize < 0)) - return qMakePair(nullptr, nullptr); + return {}; const qptrdiff offset = dataPointer ? reinterpret_cast(dataPointer) - reinterpret_cast(data) @@ -248,7 +248,7 @@ QArrayData::reallocateUnaligned(QArrayData *data, void *dataPointer, } else { dataPointer = nullptr; } - return qMakePair(static_cast(header), dataPointer); + return {header, dataPointer}; } void QArrayData::deallocate(QArrayData *data, qsizetype objectSize, diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index ef485a7fbd..2900b0178e 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -95,7 +95,7 @@ struct QArrayData static Q_CORE_EXPORT void *allocate2(QArrayData **pdata, qsizetype capacity, AllocationOption option = QArrayData::KeepSize) noexcept; - [[nodiscard]] static Q_CORE_EXPORT QPair reallocateUnaligned(QArrayData *data, void *dataPointer, + [[nodiscard]] static Q_CORE_EXPORT std::pair reallocateUnaligned(QArrayData *data, void *dataPointer, qsizetype objectSize, qsizetype newCapacity, AllocationOption option) noexcept; static Q_CORE_EXPORT void deallocate(QArrayData *data, qsizetype objectSize, qsizetype alignment) noexcept; @@ -125,7 +125,7 @@ struct QTypedArrayData { struct AlignmentDummy { QtPrivate::AlignedQArrayData header; T data; }; - [[nodiscard]] static QPair allocate(qsizetype capacity, AllocationOption option = QArrayData::KeepSize) + [[nodiscard]] static std::pair allocate(qsizetype capacity, AllocationOption option = QArrayData::KeepSize) { static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); QArrayData *d; @@ -143,16 +143,16 @@ struct QTypedArrayData // and yet we do offer results that have stricter alignment result = __builtin_assume_aligned(result, Q_ALIGNOF(AlignmentDummy)); #endif - return qMakePair(static_cast(d), static_cast(result)); + return {static_cast(d), static_cast(result)}; } - static QPair + static std::pair reallocateUnaligned(QTypedArrayData *data, T *dataPointer, qsizetype capacity, AllocationOption option) { static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); - QPair pair = + std::pair pair = QArrayData::reallocateUnaligned(data, dataPointer, sizeof(T), capacity, option); - return qMakePair(static_cast(pair.first), static_cast(pair.second)); + return {static_cast(pair.first), static_cast(pair.second)}; } static void deallocate(QArrayData *data) noexcept diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 3969076e0c..6657d40cf9 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -47,7 +47,7 @@ public: } Q_NODISCARD_CTOR - explicit QArrayDataPointer(QPair *, T *> adata, qsizetype n = 0) noexcept + explicit QArrayDataPointer(std::pair *, T *> adata, qsizetype n = 0) noexcept : d(adata.first), ptr(adata.second), size(n) { } -- cgit v1.2.3