-
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 append_range, assign_range, insert_range and prepend_range to std…
…::list
- Loading branch information
Showing
5 changed files
with
260 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,65 @@ | ||
# append_range | ||
* list[meta header] | ||
* std[meta namespace] | ||
* list[meta class] | ||
* function template[meta id-type] | ||
* cpp23[meta cpp] | ||
|
||
```cpp | ||
template <container-compatible-range<T> R> | ||
void append_range(R&& rg); // C++23 | ||
``` | ||
## 概要 | ||
Rangeの要素を末尾へ追加する。 | ||
## テンプレートパラメータ制約 | ||
型`T`が`*ranges::begin(rg)`から`list`コンテナへの`EmplaceConstructible`であること。 | ||
## 効果 | ||
Range`rg`の各要素を、末尾に追加する。 | ||
## 戻り値 | ||
なし | ||
## 計算量 | ||
`N =` [`ranges::distance`](../../iterator/ranges_distance.md)`(rg)`とすると、`N`に比例。Tのコンストラクタは`N`回呼ばれる。 | ||
## 例 | ||
```cpp example | ||
#include <iostream> | ||
#include <list> | ||
int main() | ||
{ | ||
std::list<int> lst = {1, 2, 3}; | ||
const int a[3] = {4, 5, 6}; | ||
// Rangeを末尾に追加 | ||
lst.append_range(a); | ||
for (int i : lst) { | ||
std::cout << i << " "; | ||
} | ||
std::cout << std::endl; | ||
} | ||
``` | ||
* append_range[color ff0000] | ||
|
||
### 出力 | ||
``` | ||
1 2 3 4 5 6 | ||
``` | ||
|
||
|
||
## 関連項目 | ||
|
||
| 名前 | 説明 | | ||
|-------------------------------------------|----------------------| | ||
| [`push_back`](push_back.md) | 末尾に要素を追加する | | ||
| [`emplace_back`](emplace_back.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,64 @@ | ||
# assign_range | ||
* list[meta header] | ||
* std[meta namespace] | ||
* 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)`から`list`コンテナへの`EmplaceConstructible`であること。 | ||
## 効果 | ||
Range`rg`の各要素を、再代入する。 | ||
## 戻り値 | ||
なし | ||
## 例 | ||
```cpp example | ||
#include <iostream> | ||
#include <list> | ||
int main() | ||
{ | ||
std::list<int> lst = {1, 2, 3}; | ||
const int a[3] = {4, 5, 6}; | ||
// Rangeを再代入 | ||
lst.assign_range(a); | ||
for (int i : lst) { | ||
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,62 @@ | ||
# insert_range | ||
* list[meta header] | ||
* std[meta namespace] | ||
* list[meta class] | ||
* function template[meta id-type] | ||
* cpp23[meta cpp] | ||
|
||
```cpp | ||
template <container-compatible-range<T> R> | ||
iterator insert_range(const_iterator pos, R&& rg); // C++23 | ||
``` | ||
## 概要 | ||
Rangeの各要素を任意の位置に挿入する。 | ||
## テンプレートパラメータ制約 | ||
型`T`が`*ranges::begin(rg)`から`list`コンテナへの`EmplaceConstructible`であること。 | ||
## 効果 | ||
Range`rg`の各要素を、`pos`の直前に挿入する。 | ||
## 戻り値 | ||
挿入されたRange`rg`の最初の要素を指すイテレータ。`rg`が空の場合は`pos`。 | ||
## 例 | ||
```cpp example | ||
#include <iostream> | ||
#include <iterator> | ||
#include <list> | ||
int main() | ||
{ | ||
std::list<int> lst = {1, 2, 3}; | ||
const int a[3] = {4, 5, 6}; | ||
// Rangeを1番目と2番目の要素の間に挿入 | ||
lst.insert_range(std::next(lst.begin()), a); | ||
for (int i : lst) { | ||
std::cout << i << " "; | ||
} | ||
std::cout << std::endl; | ||
} | ||
``` | ||
* insert_range[color ff0000] | ||
|
||
### 出力 | ||
``` | ||
1 4 5 6 2 3 | ||
``` | ||
|
||
|
||
## 関連項目 | ||
|
||
| 名前 | 説明 | | ||
|-------------------------------------------|----------------------| | ||
| [`insert`](insert.md) | 任意の位置に要素を挿入する | | ||
| [`emplace`](emplace.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,65 @@ | ||
# prepend_range | ||
* list[meta header] | ||
* std[meta namespace] | ||
* 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)`から`list`コンテナへの`EmplaceConstructible`であること。 | ||
## 効果 | ||
Range`rg`の各要素を、先頭に追加する。 | ||
## 戻り値 | ||
なし | ||
## 計算量 | ||
`N =` [`ranges::distance`](../../iterator/ranges_distance.md)`(rg)`とすると、`N`に比例。Tのコンストラクタは`N`回呼ばれる。 | ||
## 例 | ||
```cpp example | ||
#include <iostream> | ||
#include <list> | ||
int main() | ||
{ | ||
std::list<int> lst = {1, 2, 3}; | ||
const int a[3] = {4, 5, 6}; | ||
// Rangeを先頭に追加 | ||
lst.prepend_range(a); | ||
for (int i : lst) { | ||
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) | 先頭に要素を直接構築で追加する | |