diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-05-28 16:41:49 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-06-03 15:14:42 +0200 |
commit | e4079eca49adce16e31dac2a18d49d7a55817891 (patch) | |
tree | 1dfb960ec1115b1f552afe8a013058542389505e /src/corelib/tools/qscopeguard.h | |
parent | f32a6cfb6b6236533508901f114ab57396da8ff3 (diff) | |
parent | ec6dc5f78453048c4f0604655a34c6c20c79d819 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Take 5.
Change-Id: Ifb2d20e95ba824e45e667fba6c2ba45389991cc3
Diffstat (limited to 'src/corelib/tools/qscopeguard.h')
-rw-r--r-- | src/corelib/tools/qscopeguard.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/corelib/tools/qscopeguard.h b/src/corelib/tools/qscopeguard.h index 41d0a6af68..45c3f93da4 100644 --- a/src/corelib/tools/qscopeguard.h +++ b/src/corelib/tools/qscopeguard.h @@ -51,8 +51,9 @@ template <typename F> QScopeGuard<F> qScopeGuard(F f); template <typename F> class -#ifndef __INTEL_COMPILER -// error #2621: attribute "__warn_unused_result__" does not apply here +#if QT_HAS_CPP_ATTRIBUTE(nodiscard) +// Q_REQUIRED_RESULT can be defined as __warn_unused_result__ or as [[nodiscard]] +// but the 1st one has some limitations for example can be placed only on functions. Q_REQUIRED_RESULT #endif QScopeGuard @@ -60,9 +61,8 @@ QScopeGuard public: QScopeGuard(QScopeGuard &&other) noexcept : m_func(std::move(other.m_func)) - , m_invoke(other.m_invoke) + , m_invoke(qExchange(other.m_invoke, false)) { - other.dismiss(); } ~QScopeGuard() @@ -77,7 +77,7 @@ public: } private: - explicit QScopeGuard(F f) noexcept + explicit QScopeGuard(F &&f) noexcept : m_func(std::move(f)) { } @@ -91,8 +91,7 @@ private: template <typename F> -#ifndef __INTEL_COMPILER -// Causes "error #3058: GNU attributes on a template redeclaration have no effect" +#if QT_HAS_CPP_ATTRIBUTE(nodiscard) Q_REQUIRED_RESULT #endif QScopeGuard<F> qScopeGuard(F f) |