summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-09-06 17:22:34 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-09-08 15:43:16 +0200
commitc44e3b119af7d306378f3a9085d084c0b7cd21e0 (patch)
tree072796df349eb7698b637b58e4acedf686ae8e1f /src/corelib/global
parent8337493301ae25e5afaa94777c0ee0d1e6503660 (diff)
Add a conditional noexcept specification to qExchange
Following P2401 (which libstdc++ and MS-STL already implement) and [res.on.exception.handling]/5 that gives us freedom to strenghten any noexcept specification. Change-Id: I17ebd9148a181eb8496ace3a9d8010008160b564 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qglobal.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 6467ba1984..3fabac3888 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1204,6 +1204,7 @@ void qAsConst(const T &&) = delete;
// like std::exchange
template <typename T, typename U = T>
constexpr T qExchange(T &t, U &&newValue)
+noexcept(std::conjunction_v<std::is_nothrow_move_constructible<T>, std::is_nothrow_assignable<T &, U>>)
{
T old = std::move(t);
t = std::forward<U>(newValue);