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>
This commit is contained in:
parent
82d90fbb9e
commit
735e2f787a
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user