Skip to content

Commit

Permalink
add assign_range, insert_range_after and prepend_range to std::forwar…
Browse files Browse the repository at this point in the history
…d_list
  • Loading branch information
suomesta committed Aug 11, 2024
1 parent 1a35e93 commit d3eeb80
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 0 deletions.
3 changes: 3 additions & 0 deletions reference/forward_list/forward_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace std {
| [`(destructor)`](forward_list/op_destructor.md) | デストラクタ | C++11 |
| [`operator=`](forward_list/op_assign.md) | 代入演算子 | C++11 |
| [`assign`](forward_list/assign.md) | コンテナの再代入 | C++11 |
| [`assign_range`](forward_list/assign_range.md) | Rangeの要素を再代入 | C++23 |
### イテレータ
Expand Down Expand Up @@ -83,9 +84,11 @@ namespace std {
|----------------------------------------------------|--------------------------------|-------|
| [`emplace_front`](forward_list/emplace_front.md) | 先頭への直接構築による要素追加 | C++11 |
| [`push_front`](forward_list/push_front.md) | 先頭に要素を追加する | C++11 |
| [`prepend_range`](forward_list/prepend_range.md) | 先頭にRangeの要素を追加する | C++23 |
| [`pop_front`](forward_list/pop_front.md) | 先頭から要素を削除 | C++11 |
| [`emplace_after`](forward_list/emplace_after.md) | 任意の位置への直接構築による要素挿入 | C++11 |
| [`insert_after`](forward_list/insert_after.md) | 任意の位置への要素挿入 | C++11 |
| [`insert_range_after`](forward_list/insert_range_after.md) | 任意の位置へRangeの要素挿入 | C++23 |
| [`erase_after`](forward_list/erase_after.md) | 指定したイテレータの次の要素を削除する | C++11 |
| [`swap`](forward_list/swap.md) | コンテナの交換 | C++11 |
| [`resize`](forward_list/resize.md) | 要素数を変更する | C++11 |
Expand Down
64 changes: 64 additions & 0 deletions reference/forward_list/forward_list/assign_range.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# assign_range
* forward_list[meta header]
* std[meta namespace]
* forward_list[meta class]
* function template[meta id-type]
* cpp23[meta cpp]

```cpp
template <container-compatible-range<T> R>
void assign_range(R&& rg); // C++23
```
## 概要
Rangeの各要素を再代入する。
## 事前条件
`*this` の要素の範囲と Range`rg` の要素の範囲が重複していないこと
## テンプレートパラメータ制約
型`T`が`*ranges::begin(rg)`から`forward_list`コンテナへの`EmplaceConstructible`であること。
## 効果
Range`rg`の各要素を、再代入する。
## 戻り値
なし
## 例
```cpp example
#include <forward_list>
#include <iostream>
int main()
{
std::forward_list<int> fl = {1, 2, 3};
const int a[3] = {4, 5, 6};
// Rangeを再代入
fl.assign_range(a);
for (int i : fl) {
std::cout << i << " ";
}
std::cout << std::endl;
}
```
* assign_range[color ff0000]

### 出力
```
4 5 6
```


## 関連項目

| 名前 | 説明 |
|-------------------------------------------|----------------------|
| [`assign`](assign.md) | コンテナに値を代入する |
61 changes: 61 additions & 0 deletions reference/forward_list/forward_list/insert_range_after.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# insert_range_after
* forward_list[meta header]
* std[meta namespace]
* forward_list[meta class]
* function template[meta id-type]
* cpp23[meta cpp]

```cpp
template <container-compatible-range<T> R>
iterator insert_range_after(const_iterator pos, R&& rg); // C++23
```
## 概要
Rangeの各要素を任意の位置に挿入する。
## テンプレートパラメータ制約
型`T`が`*ranges::begin(rg)`から`forward_list`コンテナへの`EmplaceConstructible`であること。
## 効果
Range`rg`の各要素を、`pos`の直後に挿入する。
## 戻り値
挿入されたRange`rg`の最後の要素を指すイテレータ。`rg`が空の場合は`pos`。
## 例
```cpp example
#include <forward_list>
#include <iostream>
int main()
{
std::forward_list<int> fl = {1, 2, 3};
const int a[3] = {4, 5, 6};
// Rangeを1番目の直後に挿入
fl.insert_range_after(fl.begin(), a);
for (int i : fl) {
std::cout << i << " ";
}
std::cout << std::endl;
}
```
* insert_range_after[color ff0000]

### 出力
```
1 4 5 6 2 3
```


## 関連項目

| 名前 | 説明 |
|-------------------------------------------|----------------------|
| [`insert_after`](insert_after.md) | 任意の位置への要素挿入 |
| [`emplace_after`](emplace_after.md) | 任意の位置への直接構築による要素挿入 |
57 changes: 57 additions & 0 deletions reference/forward_list/forward_list/prepend_range.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# prepend_range
* forward_list[meta header]
* std[meta namespace]
* forward_list[meta class]
* function template[meta id-type]
* cpp23[meta cpp]

```cpp
template <container-compatible-range<T> R>
void prepend_range(R&& rg); // C++23
```
## 概要
先頭にRangeの要素を追加する。
## テンプレートパラメータ制約
型`T`が`*ranges::begin(rg)`から`forward_list`コンテナへの`EmplaceConstructible`であること。
## 戻り値
なし
## 例
```cpp example
#include <forward_list>
#include <iostream>
int main()
{
std::forward_list<int> fl = {1, 2, 3};
const int a[3] = {4, 5, 6};
// Rangeを先頭に追加
fl.prepend_range(a);
for (int i : fl) {
std::cout << i << " ";
}
std::cout << std::endl;
}
```
* prepend_range[color ff0000]

### 出力
```
4 5 6 1 2 3
```


## 関連項目

| 名前 | 説明 |
|-------------------------------------------|----------------------|
| [`push_front`](push_front.md) | 先頭に要素を追加する |
| [`emplace_front`](emplace_front.md) | 先頭に要素を直接構築で追加する |

0 comments on commit d3eeb80

Please sign in to comment.