-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add assign_range, insert_range_after and prepend_range to std::forwar…
…d_list
- Loading branch information
Showing
4 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | コンテナに値を代入する | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | 任意の位置への直接構築による要素挿入 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | 先頭に要素を直接構築で追加する | |