namespace std {
template <class T, class Allocator>
void swap(hive<T, Allocator>& x,
hive<T, Allocator>& y) noexcept(noexcept(x.swap(y))); // (1) C++26
}
概要
2つのhiveオブジェクトを入れ替える。
効果
x.swap(y)と等価である。
戻り値
なし
例
#include <hive>
#include <print>
void print(const char* name, const std::hive<int>& h)
{
std::print("{} : ", name);
for (int x : h) {
std::print("{} ", x);
}
std::println("");
}
int main()
{
std::hive<int> h1 = {1, 2, 3};
std::hive<int> h2 = {4, 5, 6};
std::swap(h1, h2);
print("h1", h1);
print("h2", h2);
}
出力
h1 : 4 5 6
h2 : 1 2 3
バージョン
言語
- C++26
処理系
- Clang: 22 ❌
- GCC: 16.1 ❌
- Visual C++: 2026 Update 2 ❌
関連項目
参照
- P0447R28 Introduction of
std::hiveto the standard library- C++26で
hiveが追加された
- C++26で