summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2021-12-13 12:29:51 +0100
committerMarc Mutz <marc.mutz@qt.io>2021-12-16 12:47:39 +0100
commit735e2f787acf1f74c00e26730c7a477a7a59129f (patch)
treedea7aea42e1b985229d444f6ae80fb9ad8d21da3
parent82d90fbb9ef70bea6d1e13d6c84ff734c6a828c8 (diff)
QRingBuffer: simplify QRingChunk special member functions [1/2]
Let the compiler generate the copy and move SMFs. Statically assert that the move SMFs are still noexcept. Pick-to: 6.3 Change-Id: I1c569bdf893a5f2cda972c0dd8196cab62494fcb Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r--src/corelib/tools/qringbuffer.cpp8
-rw-r--r--src/corelib/tools/qringbuffer_p.h20
2 files changed, 8 insertions, 20 deletions
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp
index f32673b9bd..b10362b0cd 100644
--- a/src/corelib/tools/qringbuffer.cpp
+++ b/src/corelib/tools/qringbuffer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Copyright (C) 2015 Alex Trotsenko <alex1973tr@gmail.com>
** Contact: https://www.qt.io/licensing/
**
@@ -40,10 +40,16 @@
#include "private/qringbuffer_p.h"
#include "private/qbytearray_p.h"
+
+#include <type_traits>
+
#include <string.h>
QT_BEGIN_NAMESPACE
+static_assert(std::is_nothrow_move_constructible_v<QRingChunk>);
+static_assert(std::is_nothrow_move_assignable_v<QRingChunk>);
+
void QRingChunk::allocate(qsizetype alloc)
{
Q_ASSERT(alloc > 0 && size() == 0);
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index 1ab0053d1a..84e0f9ddec 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -69,10 +69,6 @@ public:
headOffset(0), tailOffset(0)
{
}
- inline QRingChunk(const QRingChunk &other) noexcept :
- chunk(other.chunk), headOffset(other.headOffset), tailOffset(other.tailOffset)
- {
- }
explicit inline QRingChunk(qsizetype alloc) :
chunk(alloc, Qt::Uninitialized), headOffset(0), tailOffset(0)
{
@@ -86,20 +82,6 @@ public:
{
}
- inline QRingChunk &operator=(const QRingChunk &other) noexcept
- {
- chunk = other.chunk;
- headOffset = other.headOffset;
- tailOffset = other.tailOffset;
- return *this;
- }
- inline QRingChunk(QRingChunk &&other) noexcept :
- chunk(other.chunk), headOffset(other.headOffset), tailOffset(other.tailOffset)
- {
- other.headOffset = other.tailOffset = 0;
- }
- QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QRingChunk)
-
inline void swap(QRingChunk &other) noexcept
{
chunk.swap(other.chunk);