Skip to content

Commit

Permalink
add swap_free.md to flat_set (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
suomesta committed Feb 9, 2025
1 parent f28cc8b commit 304f099
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 2 deletions.
2 changes: 1 addition & 1 deletion reference/flat_set/flat_multiset.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ namespace std {
| 名前 | 説明 | 対応バージョン |
|------|------|----------------|
| [`swap`](flat_multiset/swap_free.md.nolink) | 2つの`flat_multiset`オブジェクトを入れ替える | C++23 |
| [`swap`](flat_multiset/swap_free.md) | 2つの`flat_multiset`オブジェクトを入れ替える | C++23 |
## 推論補助
Expand Down
76 changes: 76 additions & 0 deletions reference/flat_set/flat_multiset/swap_free.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# swap (非メンバ関数)
* flat_set[meta header]
* std[meta namespace]
* function template[meta id-type]
* cpp23[meta cpp]

```cpp
namespace std {
template <class Key, class Compare, class KeyContainer>
void swap(flat_multiset<Key, Compare, KeyContainer>& x,
flat_multiset<Key, Compare, KeyContainer>& y); // (1) C++23
}
```
## 概要
2つの `flat_multiset` オブジェクトを入れ替える。
## 効果
`x.`[`swap`](swap.md)`(y)`
## 例
```cpp example
#include <flat_set>
#include <iostream>
template <class Set>
void print(const char* name, const Set& s)
{
std::cout << name << " : {";
bool first = true;
for (const auto& x : s) {
if (first) {
first = false;
}
else {
std::cout << ", ";
}
std::cout << x;
}
std::cout << "}" << std::endl;
}
int main()
{
std::flat_multiset<int> fs1 = {10, 20, 30};
std::flat_multiset<int> fs2 = {5, 15};
// fs1とfs2を入れ替える
std::swap(fs1, fs2);
print("fs1", fs1);
print("fs2", fs2);
}
```
* std::swap[color ff0000]

### 出力
```
fs1 : {5, 15}
fs2 : {10, 20, 30}
```


## バージョン
### 言語
- C++23

### 処理系
- [Clang](/implementation.md#clang): ??
- [GCC](/implementation.md#gcc): ??
- [Visual C++](/implementation.md#visual_cpp): ??
2 changes: 1 addition & 1 deletion reference/flat_set/flat_set.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ namespace std {
| 名前 | 説明 | 対応バージョン |
|------|------|----------------|
| [`swap`](flat_set/swap_free.md.nolink) | 2つの`flat_set`オブジェクトを入れ替える | C++23 |
| [`swap`](flat_set/swap_free.md) | 2つの`flat_set`オブジェクトを入れ替える | C++23 |
## 推論補助
Expand Down
76 changes: 76 additions & 0 deletions reference/flat_set/flat_set/swap_free.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# swap (非メンバ関数)
* flat_set[meta header]
* std[meta namespace]
* function template[meta id-type]
* cpp23[meta cpp]

```cpp
namespace std {
template <class Key, class Compare, class KeyContainer>
void swap(flat_set<Key, Compare, KeyContainer>& x,
flat_set<Key, Compare, KeyContainer>& y); // (1) C++23
}
```
## 概要
2つの `flat_set` オブジェクトを入れ替える。
## 効果
`x.`[`swap`](swap.md)`(y)`
## 例
```cpp example
#include <flat_set>
#include <iostream>
template <class Set>
void print(const char* name, const Set& s)
{
std::cout << name << " : {";
bool first = true;
for (const auto& x : s) {
if (first) {
first = false;
}
else {
std::cout << ", ";
}
std::cout << x;
}
std::cout << "}" << std::endl;
}
int main()
{
std::flat_set<int> fs1 = {10, 20, 30};
std::flat_set<int> fs2 = {5, 15};
// fs1とfs2を入れ替える
std::swap(fs1, fs2);
print("fs1", fs1);
print("fs2", fs2);
}
```
* std::swap[color ff0000]

### 出力
```
fs1 : {5, 15}
fs2 : {10, 20, 30}
```


## バージョン
### 言語
- C++23

### 処理系
- [Clang](/implementation.md#clang): ??
- [GCC](/implementation.md#gcc): ??
- [Visual C++](/implementation.md#visual_cpp): ??

0 comments on commit 304f099

Please sign in to comment.