Skip to content

Commit

Permalink
flat_map : clearを追加 #1078
Browse files Browse the repository at this point in the history
  • Loading branch information
faithandbrave committed May 24, 2023
1 parent 9430b41 commit d6e40dd
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
2 changes: 1 addition & 1 deletion reference/flat_map/flat_map.md
Expand Up @@ -57,7 +57,7 @@ namespace std {
| 名前 | 説明 | 対応バージョン |
|-----------------------------------------------|--------------------------------------------|----------------|
| [`clear`](flat_map/clear.md.nolink) | 全ての要素を削除する | C++23 |
| [`clear`](flat_map/clear.md) | 全ての要素を削除する | C++23 |
| [`insert`](flat_map/insert.md.nolink) | 要素を挿入する | C++23 |
| [`insert_or_assign`](flat_map/insert_or_assign.md.nolink) | 要素を挿入、あるいは代入する | C++23 |
| [`insert_range`](flat_map/insert_range.md.nolink) | Rangeを挿入する | C++23 |
Expand Down
61 changes: 61 additions & 0 deletions reference/flat_map/flat_map/clear.md
@@ -0,0 +1,61 @@
# clear
* flat_map[meta header]
* std[meta namespace]
* flat_map[meta class]
* function[meta id-type]
* cpp23[meta cpp]

```cpp
void clear() noexcept; // (1) C++23
```

## 概要
コンテナ内の全ての要素を削除する。それぞれのデストラクタが呼ばれ、コンテナから削除される。[`size()`](size.md) は 0 になる。


## 計算量
線形時間


## 例外

投げない

##
```cpp example
#include <iostream>
#include <flat_map>

int main ()
{
std::flat_map<int, char> fm = {
{3, 'C'},
{4, 'D'},
{1, 'A'},
{2, 'B'},
};

std::cout << fm.size() << std::endl;

fm.clear();

std::cout << fm.size() << std::endl;
}
```
* clear()[color ff0000]
* fm.size()[link size.md]

### 出力
```
4
0
```

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

### 処理系
- [Clang](/implementation.md#clang): ??
- [GCC](/implementation.md#gcc): ??
- [Visual C++](/implementation.md#visual_cpp): ??
2 changes: 1 addition & 1 deletion reference/flat_map/flat_map/empty.md
Expand Up @@ -13,7 +13,7 @@
コンテナが空かどうかをテストする。
コンテナが空([`size()`](size.md) が 0)の場合に `true` を返す。

この関数はコンテナ内のコンテンツを変化させない。コンテンツをクリアするには [`clear()`](clear.md.nolink) メンバ関数を使用する。
この関数はコンテナ内のコンテンツを変化させない。コンテンツをクリアするには [`clear()`](clear.md) メンバ関数を使用する。


## 戻り値
Expand Down

0 comments on commit d6e40dd

Please sign in to comment.