Skip to content

Commit 3602f00

Browse files
committed
Range adaptor helpersの説明専用ライブラリを追加
1 parent 0059bf7 commit 3602f00

File tree

7 files changed

+149
-1
lines changed

7 files changed

+149
-1
lines changed

reference/exposition-only.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@
4848
| [`uses-nonqualification-pointer-conversion`](ranges/subrange/uses-nonqualification-pointer-conversion.md) | 直接変換できない型同士のポインタの変換が必要かどうかを表す (concept) | C++20 |
4949
| [`convertible-to-non-slicing`](ranges/subrange/convertible-to-non-slicing.md) | スライシングを起こさずに変換できるかどうかを表す (concept) | C++20 |
5050
| [`pair-like-convertible-from`](ranges/subrange/pair-like-convertible-from.md) | ある2つの型から構築出来る[`pair-like`](tuple/pair-like.md)な型を表す (concept) | C++20 |
51-
| [`maybe-const`](ranges/maybe-const.md) | bool値に応じて`const`修飾を付加する (alias template) | C++23 |
51+
| [`maybe-const`](ranges/maybe-const.md) | bool値に応じて`const`修飾を付加する (alias template) | C++23 |
52+
| [`tuple-transform`](ranges/tuple-transform.md) | [`tuple`](tuple/tuple.md)の各要素に関数を適用した[`tuple`](tuple/tuple.md)を生成する (function template) | C++23 |
53+
| [`tuple-for-each`](ranges/tuple-for-each.md) | [`tuple`](tuple/tuple.md)の各要素に関数を適用する (function template) | C++23 |
54+
| [`as-lvalue`](ranges/as-lvalue.md) | rvalueをlvalueへキャストする (function template) | C++23 |
55+
| [`all-random-access`](ranges/all-random-access.md) | すべてのビューが[`random_access_range`](ranges/random_access_range.md)であるかを表す (concept) | C++26 |
56+
| [`all-bidirectional`](ranges/all-bidirectional.md) | すべてのビューが[`bidirectional_range`](ranges/bidirectional_range.md)であるかを表す (concept) | C++26 |
57+
| [`all-forward`](ranges/all-forward.md) | すべてのビューが[`forward_range`](ranges/forward_range.md)であるかを表す (concept) | C++26 |
5258

5359
## `<tuple>`
5460

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# all-bidirectional
2+
* ranges[meta header]
3+
* concept[meta id-type]
4+
* cpp26[meta cpp]
5+
6+
```cpp
7+
namespace std::ranges {
8+
template<bool Const, class... Views>
9+
concept all-bidirectional = (bidirectional_range<maybe-const<Const, Views>> && ...);
10+
}
11+
```
12+
13+
## 概要
14+
15+
`all-bidirectional` は、複数のビューに対し、それらすべてが [`bidirectional_range`](bidirectional_range.md) であることを表すコンセプトである。
16+
17+
## バージョン
18+
### 言語
19+
- C++26
20+
21+
## 参照
22+
- [26.7.5 Range adaptor helpers](https://eel.is/c++draft/range.adaptor.helpers)

reference/ranges/all-forward.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# all-forward
2+
* ranges[meta header]
3+
* concept[meta id-type]
4+
* cpp26[meta cpp]
5+
6+
```cpp
7+
namespace std::ranges {
8+
template<bool Const, class... Views>
9+
concept all-forward = (forward_range<maybe-const<Const, Views>> && ...);
10+
}
11+
```
12+
13+
## 概要
14+
15+
`all-forward` は、複数のビューに対し、それらすべてが [`forward_range`](forward_range.md) であることを表すコンセプトである。
16+
17+
## バージョン
18+
### 言語
19+
- C++26
20+
21+
## 参照
22+
- [26.7.5 Range adaptor helpers](https://eel.is/c++draft/range.adaptor.helpers)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# all-random-access
2+
* ranges[meta header]
3+
* concept[meta id-type]
4+
* cpp26[meta cpp]
5+
6+
```cpp
7+
namespace std::ranges {
8+
template<bool Const, class... Views>
9+
concept all-random-access = (random_access_range<maybe-const<Const, Views>> && ...);
10+
}
11+
```
12+
13+
## 概要
14+
15+
`all-random-access` は、複数のビューに対し、それらすべてが [`random_access_range`](random_access_range.md) であることを表すコンセプトである。
16+
17+
## バージョン
18+
### 言語
19+
- C++26
20+
21+
## 参照
22+
- [26.7.5 Range adaptor helpers](https://eel.is/c++draft/range.adaptor.helpers)

reference/ranges/as-lvalue.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# as-lvalue
2+
* ranges[meta header]
3+
* function template[meta id-type]
4+
* cpp23[meta cpp]
5+
6+
```cpp
7+
namespace std::ranges {
8+
template<class T>
9+
constexpr T& as-lvalue(T&& t) {
10+
return static_cast<T&>(t);
11+
}
12+
}
13+
```
14+
15+
## 概要
16+
17+
`as-lvalue` は、rvalueをlvalueへキャストする説明専用の関数である。
18+
19+
## バージョン
20+
### 言語
21+
- C++23
22+
23+
## 参照
24+
- [N4950 26 Ranges library](https://timsong-cpp.github.io/cppwp/n4950/ranges)

reference/ranges/tuple-for-each.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# tuple-for-each
2+
* ranges[meta header]
3+
* function template[meta id-type]
4+
* cpp23[meta cpp]
5+
6+
```cpp
7+
namespace std::ranges {
8+
template<class F, class Tuple>
9+
constexpr void tuple-for-each(F&& f, Tuple&& t) {
10+
apply([&]<class... Ts>(Ts&&... elements) {
11+
(static_cast<void>(invoke(f, std::forward<Ts>(elements))), ...);
12+
}, std::forward<Tuple>(t));
13+
}
14+
}
15+
```
16+
17+
## 概要
18+
19+
`tuple-for-each` は、[`tuple`](/reference/tuple/tuple.md)の各要素に対して関数を適用する説明専用の関数テンプレートである。
20+
21+
## バージョン
22+
### 言語
23+
- C++23
24+
25+
## 参照
26+
- [N4950 26 Ranges library](https://timsong-cpp.github.io/cppwp/n4950/ranges)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# tuple-transform
2+
* ranges[meta header]
3+
* function template[meta id-type]
4+
* cpp23[meta cpp]
5+
6+
```cpp
7+
namespace std::ranges {
8+
template<class F, class Tuple>
9+
constexpr auto tuple-transform(F&& f, Tuple&& t) {
10+
return apply([&]<class... Ts>(Ts&&... elements) {
11+
return tuple<invoke_result_t<F&, Ts>...>(invoke(f, std::forward<Ts>(elements))...);
12+
}, std::forward<Tuple>(t));
13+
}
14+
}
15+
```
16+
17+
## 概要
18+
19+
`tuple-transform` は、[`tuple`](/reference/tuple/tuple.md)の各要素に対して関数を適用し、それらの結果を要素とする[`tuple`](/reference/tuple/tuple.md)を生成する説明専用の関数テンプレートである。
20+
21+
## バージョン
22+
### 言語
23+
- C++23
24+
25+
## 参照
26+
- [N4950 26 Ranges library](https://timsong-cpp.github.io/cppwp/n4950/ranges)

0 commit comments

Comments
 (0)