Div. private RAII/smart ptr classes: mark ctors [[nodiscard]]
The following private APIs are either RAII or smart pointer classes: - QAutoPointer - QBoolBlocker - QFdContainer QUIP-0019 says to mark RAII and smart pointer class ctors [[nodiscard]], so do that. Task-number: QTBUG-104164 Change-Id: Ibc77e6603fadf18ea28428a49635f46a5680b777 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit 25e20d5537b2a7682c34a9837076530ad220b3b5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
53f88aa737
commit
15b9a1e6d5
@ -434,7 +434,9 @@ class QBoolBlocker
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QBoolBlocker)
|
||||
public:
|
||||
explicit inline QBoolBlocker(bool &b, bool value = true) : block(b), reset(b) { block = value; }
|
||||
Q_NODISCARD_CTOR explicit QBoolBlocker(bool &b, bool value = true)
|
||||
: block(b), reset(b)
|
||||
{ block = value; }
|
||||
inline ~QBoolBlocker() { block = reset; }
|
||||
|
||||
private:
|
||||
|
@ -101,7 +101,7 @@ class QFdContainer
|
||||
int m_fd;
|
||||
Q_DISABLE_COPY_MOVE(QFdContainer);
|
||||
public:
|
||||
explicit QFdContainer(int fd = -1) noexcept : m_fd(fd) {}
|
||||
Q_NODISCARD_CTOR explicit QFdContainer(int fd = -1) noexcept : m_fd(fd) {}
|
||||
~QFdContainer() { reset(); }
|
||||
|
||||
int get() const noexcept { return m_fd; }
|
||||
|
@ -103,7 +103,7 @@ template <typename T>
|
||||
class QAutoPointer {
|
||||
QPointer<T> o;
|
||||
public:
|
||||
explicit QAutoPointer(T *t) noexcept : o(t) {}
|
||||
Q_NODISCARD_CTOR explicit QAutoPointer(T *t) noexcept : o(t) {}
|
||||
~QAutoPointer() { delete o; }
|
||||
|
||||
T *operator->() const noexcept { return get(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user