diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-17 13:40:00 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-23 09:50:21 +0100 |
commit | f61f8bb966fdc04662fb4e6597698b573fcb8b94 (patch) | |
tree | 80871d6271c059376edb205b8aa69d0b4621c9a3 /src/corelib | |
parent | 03ab48657d0486bd0e3754f1447a6fcd05846a5d (diff) |
Replace qt_make_unique with std::make_unique
We can depend on C++14 now.
Change-Id: Iee9796cd22dbfbb70d4bdb25f0eee1662a026d6d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/corelib/global/global.pri | 1 | ||||
-rw-r--r-- | src/corelib/global/qmemory_p.h | 71 | ||||
-rw-r--r-- | src/corelib/io/qfile.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qfiledevice.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qurl.cpp | 5 | ||||
-rw-r--r-- | src/corelib/serialization/qjsondocument.cpp | 16 | ||||
-rw-r--r-- | src/corelib/serialization/qxmlstream.cpp | 3 |
8 files changed, 13 insertions, 94 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 11b3c220c8..18345a2fde 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -43,7 +43,6 @@ qt_internal_add_module(Core global/qlibraryinfo.cpp global/qlibraryinfo.h global/qlogging.cpp global/qlogging.h global/qmalloc.cpp - global/qmemory_p.h # global/qnamespace.h # special case global/qnumeric.cpp global/qnumeric.h global/qnumeric_p.h global/qoperatingsystemversion.cpp global/qoperatingsystemversion.h global/qoperatingsystemversion_p.h diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index 4e9a0a0c8b..5850792bdb 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -8,7 +8,6 @@ HEADERS += \ global/qcompilerdetection.h \ global/qcontainerinfo.h \ global/qprocessordetection.h \ - global/qmemory_p.h \ global/qnamespace.h \ global/qendian.h \ global/qendian_p.h \ diff --git a/src/corelib/global/qmemory_p.h b/src/corelib/global/qmemory_p.h deleted file mode 100644 index ac791385bd..0000000000 --- a/src/corelib/global/qmemory_p.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QMEMORY_P_H -#define QMEMORY_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qglobal.h> - -#include <memory> -#include <type_traits> -#include <utility> - -QT_BEGIN_NAMESPACE - -// Like std::make_unique, but less ambitious, so keep as private API, for use in Qt itself: -template <typename T, typename... Args> -typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type -qt_make_unique(Args &&...args) -{ - return std::unique_ptr<T>{new T(std::forward<Args>(args)...)}; -} - -QT_END_NAMESPACE - -#endif /* QMEMORY_P_H */ diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 36e2b4476a..223745b73c 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -55,8 +55,6 @@ # include "qcoreapplication.h" #endif -#include <private/qmemory_p.h> - #ifdef QT_NO_QOBJECT #define tr(X) QString::fromLatin1(X) #endif @@ -87,7 +85,7 @@ QFilePrivate::openExternalFile(int flags, int fd, QFile::FileHandleFlags handleF Q_UNUSED(fd); return false; #else - auto fs = qt_make_unique<QFSFileEngine>(); + auto fs = std::make_unique<QFSFileEngine>(); auto fe = fs.get(); fileEngine = std::move(fs); return fe->open(QIODevice::OpenMode(flags), fd, handleFlags); @@ -102,7 +100,7 @@ QFilePrivate::openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handl Q_UNUSED(fh); return false; #else - auto fs = qt_make_unique<QFSFileEngine>(); + auto fs = std::make_unique<QFSFileEngine>(); auto fe = fs.get(); fileEngine = std::move(fs); return fe->open(QIODevice::OpenMode(flags), fh, handleFlags); diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp index f916071504..58c78108c8 100644 --- a/src/corelib/io/qfiledevice.cpp +++ b/src/corelib/io/qfiledevice.cpp @@ -42,8 +42,6 @@ #include "qfiledevice_p.h" #include "qfsfileengine_p.h" -#include <private/qmemory_p.h> - #ifdef QT_NO_QOBJECT #define tr(X) QString::fromLatin1(X) #endif @@ -66,7 +64,7 @@ QFileDevicePrivate::~QFileDevicePrivate() = default; QAbstractFileEngine *QFileDevicePrivate::engine() const { if (!fileEngine) - fileEngine = qt_make_unique<QFSFileEngine>(); + fileEngine = std::make_unique<QFSFileEngine>(); return fileEngine.get(); } diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 2b5839923a..b019fe65a9 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -418,7 +418,6 @@ #include "private/qipaddress_p.h" #include "qurlquery.h" #include "private/qdir_p.h" -#include <private/qmemory_p.h> QT_BEGIN_NAMESPACE @@ -617,7 +616,7 @@ inline QUrlPrivate::~QUrlPrivate() std::unique_ptr<QUrlPrivate::Error> QUrlPrivate::cloneError() const { - return error ? qt_make_unique<Error>(*error) : nullptr; + return error ? std::make_unique<Error>(*error) : nullptr; } inline void QUrlPrivate::clearError() @@ -631,7 +630,7 @@ inline void QUrlPrivate::setError(ErrorCode errorCode, const QString &source, in // don't overwrite an error set in a previous section during parsing return; } - error = qt_make_unique<Error>(); + error = std::make_unique<Error>(); error->code = errorCode; error->source = source; error->position = supplement; diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp index 6ef657d50d..6b015d759d 100644 --- a/src/corelib/serialization/qjsondocument.cpp +++ b/src/corelib/serialization/qjsondocument.cpp @@ -52,8 +52,6 @@ #include "qjson_p.h" #include "qdatastream.h" -#include <private/qmemory_p.h> - QT_BEGIN_NAMESPACE /*! \class QJsonDocument @@ -139,7 +137,7 @@ QJsonDocument::QJsonDocument(const QJsonArray &array) \internal */ QJsonDocument::QJsonDocument(const QCborValue &data) - : d(qt_make_unique<QJsonDocumentPrivate>(data)) + : d(std::make_unique<QJsonDocumentPrivate>(data)) { Q_ASSERT(d); } @@ -158,7 +156,7 @@ QJsonDocument::QJsonDocument(const QJsonDocument &other) { if (other.d) { if (!d) - d = qt_make_unique<QJsonDocumentPrivate>(); + d = std::make_unique<QJsonDocumentPrivate>(); d->value = other.d->value; } else { d.reset(); @@ -184,7 +182,7 @@ QJsonDocument &QJsonDocument::operator =(const QJsonDocument &other) if (this != &other) { if (other.d) { if (!d) - d = qt_make_unique<QJsonDocumentPrivate>(); + d = std::make_unique<QJsonDocumentPrivate>(); else d->clearRawData(); d->value = other.d->value; @@ -239,7 +237,7 @@ QJsonDocument QJsonDocument::fromVariant(const QVariant &variant) doc.setArray(QJsonArray::fromVariantList(variant.toList())); break; case QMetaType::QStringList: - doc.d = qt_make_unique<QJsonDocumentPrivate>(); + doc.d = std::make_unique<QJsonDocumentPrivate>(); doc.d->value = QCborArray::fromStringList(variant.toStringList()); break; default: @@ -320,7 +318,7 @@ QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *e QJsonDocument result; const QCborValue val = parser.parse(error); if (val.isArray() || val.isMap()) { - result.d = qt_make_unique<QJsonDocumentPrivate>(); + result.d = std::make_unique<QJsonDocumentPrivate>(); result.d->value = val; } return result; @@ -405,7 +403,7 @@ QJsonArray QJsonDocument::array() const void QJsonDocument::setObject(const QJsonObject &object) { if (!d) - d = qt_make_unique<QJsonDocumentPrivate>(); + d = std::make_unique<QJsonDocumentPrivate>(); else d->clearRawData(); @@ -420,7 +418,7 @@ void QJsonDocument::setObject(const QJsonObject &object) void QJsonDocument::setArray(const QJsonArray &array) { if (!d) - d = qt_make_unique<QJsonDocumentPrivate>(); + d = std::make_unique<QJsonDocumentPrivate>(); else d->clearRawData(); diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index e56877082b..769b33931e 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -63,7 +63,6 @@ public: \ { return QString::fromUtf8(sourceText); } \ private: #endif -#include <private/qmemory_p.h> #include <iterator> #include "qxmlstream_p.h" @@ -875,7 +874,7 @@ void QXmlStreamReaderPrivate::parseEntity(const QString &value) if (!entityParser) - entityParser = qt_make_unique<QXmlStreamReaderPrivate>(q); + entityParser = std::make_unique<QXmlStreamReaderPrivate>(q); else entityParser->init(); entityParser->inParseEntity = true; |