<QtSwap> Proxy Page
|void||qSwap(T &lhs, T &rhs)|
Exchanges the values of variables lhs and rhs, taking type-specific
swap() overloads into account.
This function is Qt's version of
boost::swap(), and is equivalent to
using std::swap; // bring std::swap into scope (for built-in types) swap(lhs, rhs); // unqualified call (picks up type-specific overloads // via Argument-Dependent Lookup, or falls back to std::swap)
Use this function primarily in generic code, where you would traditionally have written the above two lines, because you don't know anything about
If you already know what
T is, then use one of the following options, in order of preference:
lhs.swap(rhs);if such a member-swap exists
std::swap(lhs, rhs);if no type-specific
boost::swap() on boost.org for more details.
Note: This function does not throw any exception when "noexcept(QtPrivate::SwapExceptionTester::checkSwap(value1))" is true.
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.