From a73385e2cfd0455f09166cdb380876ba8b26fb5f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 13 May 2019 20:43:27 +0200 Subject: Short live qExchange()! This is a 1:1 replacement for std::exchange, and should be removed once Qt fully depends on C++14. It's too versatile a tool to miss it, so provide a copy. [ChangeLog][QtCore][QtGlobal] Added qExchange(), a drop-in for C++14's std::exchange() Change-Id: I31c4f1141e7a99f99ea65eb36ddf9d68b7847337 Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/corelib/global/qglobal.cpp') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 88a61562cb..3436a19881 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -3805,6 +3805,17 @@ bool qunsetenv(const char *varName) \snippet code/src_corelib_global_qglobal.cpp as-const-4 */ +/*! + \fn template T qExchange(T &obj, U &&newValue) + \relates + \since 5.14 + + Replaces the value of \a obj with \a newValue and returns the old value of \a obj. + + This is Qt's implementation of std::exchange(). It differs from std::exchange() + only in that it is \c constexpr already in C++14, and available on all supported + compilers. +*/ /*! \macro QT_TR_NOOP(sourceText) \relates -- cgit v1.2.3