summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2022-09-26 17:38:14 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2022-09-28 17:39:21 +0000
commita0dfa8c4d29a005009d04dcb52452efb9d74e26e (patch)
tree7b400e7a8fc2dd2db99d780e94ff4bf1b63ce375 /src/network
parentd06d22fbc0ef1d070408fe7e1f6a5c33e6f8c4e2 (diff)
Replace qExchange calls with std::exchange
qExchange is one of the few remaining functionalities that have not been moved out of qglobal. Given that std::exchange exists in the standard, we can simply move to it everywhere... ...if it weren't for the fact that std::exchange is only constexpr in C++20, and only has its noexceptness specified in (most likely) C++23. Still, we want to move to the existing std functionality where possible, to allow the removal of qglobal includes in lieu of something more fine-grained in the future. So leave any constexpr calls[1] alone for now (and observe that none of our current usages cares about the conditional noexceptness), but replace everything else. [1] QScopedValueRollback' ctor and QExplicitlySharedDataPointerV2::take Task-number: QTBUG-99313 Change-Id: I599cb9846cf319c7ffd3457130938347a75aad25 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttpprotocolhandler.cpp6
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp2
-rw-r--r--src/network/kernel/qhostinfo.h2
3 files changed, 5 insertions, 5 deletions
diff --git a/src/network/access/qhttpprotocolhandler.cpp b/src/network/access/qhttpprotocolhandler.cpp
index 36102909df..b2576a85e6 100644
--- a/src/network/access/qhttpprotocolhandler.cpp
+++ b/src/network/access/qhttpprotocolhandler.cpp
@@ -298,7 +298,7 @@ bool QHttpProtocolHandler::sendRequest()
sendRequest(); //recurse
} else {
// no data to send: just send the HTTP headers
- m_socket->write(qExchange(m_header, {}));
+ m_socket->write(std::exchange(m_header, {}));
QMetaObject::invokeMethod(m_reply, "requestSent", Qt::QueuedConnection);
m_channel->state = QHttpNetworkConnectionChannel::WaitingState; // now wait for response
sendRequest(); //recurse
@@ -314,7 +314,7 @@ bool QHttpProtocolHandler::sendRequest()
// the upload device might have no data to send, but we still have to send the headers,
// do it now.
if (!m_header.isEmpty())
- m_socket->write(qExchange(m_header, {}));
+ m_socket->write(std::exchange(m_header, {}));
if (uploadByteDevice)
emit m_reply->dataSendProgress(m_channel->written, m_channel->bytesTotal);
m_channel->state = QHttpNetworkConnectionChannel::WaitingState; // now wait for response
@@ -371,7 +371,7 @@ bool QHttpProtocolHandler::sendRequest()
// assemble header and data and send them together
const qint64 headerSize = m_header.size();
m_header.append(readPointer, currentReadSize);
- currentWriteSize = m_socket->write(qExchange(m_header, {}));
+ currentWriteSize = m_socket->write(std::exchange(m_header, {}));
if (currentWriteSize != -1)
currentWriteSize -= headerSize;
QMetaObject::invokeMethod(m_reply, "requestSent", Qt::QueuedConnection);
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index a1fedb4cd3..2c713e69fd 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -281,7 +281,7 @@ void QNetworkReplyImplPrivate::handleNotifications()
if (notificationHandlingPaused)
return;
- for (InternalNotifications notification : qExchange(pendingNotifications, {})) {
+ for (InternalNotifications notification : std::exchange(pendingNotifications, {})) {
if (state != Working)
return;
switch (notification) {
diff --git a/src/network/kernel/qhostinfo.h b/src/network/kernel/qhostinfo.h
index 6ee8aff081..eac23ac296 100644
--- a/src/network/kernel/qhostinfo.h
+++ b/src/network/kernel/qhostinfo.h
@@ -26,7 +26,7 @@ public:
explicit QHostInfo(int lookupId = -1);
QHostInfo(const QHostInfo &d);
- QHostInfo(QHostInfo &&other) noexcept : d_ptr(qExchange(other.d_ptr, nullptr)) {}
+ QHostInfo(QHostInfo &&other) noexcept : d_ptr(std::exchange(other.d_ptr, nullptr)) {}
QHostInfo &operator=(const QHostInfo &d);
QHostInfo &operator=(QHostInfo &&other) noexcept { swap(other); return *this; }
~QHostInfo();