std::swappable, std::swappable_with
來自 cppreference.com
定義於標頭檔案 <concepts> |
||
template< class T > concept swappable = |
(1) | (C++20 起) |
template< class T, class U > concept swappable_with = |
(2) | (C++20 起) |
概念 swappable<T>
指定型別 T
的左值是可交換的。
概念 swappable_with<T, U>
指定由 T
和 U
編碼的型別和值類別的表示式可以相互交換。當且僅當對 ranges::swap(t, u) 的呼叫交換了 t
和 u
的值時,swappable_with<T, U>
才被滿足,也就是說,給定與 t
相等的不同物件 t2
和與 u
相等的 u2
,在計算 ranges::swap(t, u) 或 ranges::swap(u, t) 之後,t2
等於 u
且 u2
等於 t
。
[編輯] 等價性保留
標準庫概念的 requires 表示式中宣告的表示式必須是等價性保留的(除非另有說明)。
[編輯] 參考
- C++23 標準 (ISO/IEC 14882:2024)
- 18.4.9 概念
swappable
[concept.swappable]
- 18.4.9 概念
- C++20 標準 (ISO/IEC 14882:2020)
- 18.4.9 概念
swappable
[concept.swappable]
- 18.4.9 概念