Implement QUniqueHandle::release() using std::exchange
This does not change the behavior of release() but gives more compact code. Task-number: QTBUG-132507 Pick-to: 6.8 Change-Id: I5b34c80409ca0e9e9a5e9aee9ef7bc80017610af Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit ec0c62385e0df00f42bc9fb5e117cb8b994cfc96) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
cdc8811492
commit
b72c4988fb
@ -19,6 +19,7 @@
|
|||||||
#include <QtCore/qassert.h>
|
#include <QtCore/qassert.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -162,9 +163,7 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] Type release() noexcept
|
[[nodiscard]] Type release() noexcept
|
||||||
{
|
{
|
||||||
Type handle = m_handle;
|
return std::exchange(m_handle, HandleTraits::invalidValue());
|
||||||
m_handle = HandleTraits::invalidValue();
|
|
||||||
return handle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] Type *operator&() noexcept // NOLINT(google-runtime-operator)
|
[[nodiscard]] Type *operator&() noexcept // NOLINT(google-runtime-operator)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user