<QtSwap>プロキシページ
関数
void | qSwap(T &lhs, T &rhs) |
関数のドキュメント
[constexpr noexcept(...)]
template <typename T> void qSwap(T &lhs, T &rhs)
変数lhs とrhs の値を交換します。型固有のswap()
オーバーロードを考慮に入れています。
この関数はQtの boost::swap()
と同等です。
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)
この関数は主にジェネリック・コードで使用します。従来は上記の2行を記述していましたが、これはT
について何も知らないためです。
T
が何であるか既に知っている場合は、次のオプションのいずれかを使用してください:
lhs.swap(rhs);
そのようなメンバー・スワップが存在する場合std::swap(lhs, rhs);
型固有の が存在しない場合swap()
cppreference.comのstd::swap
、cppreference.comのSwappable
も参照してください。
注意: std::is_nothrow_swappable_v<T>
がtrue
の場合、この関数は noexcept となります。
© 2025 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.