Skip to content

Commit e24da03

Browse files
committed
mdspan: submdspan_mapping(#1201)
1 parent 296296a commit e24da03

File tree

9 files changed

+267
-4
lines changed

9 files changed

+267
-4
lines changed

reference/mdspan/layout_left/mapping.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace std {
7676
7777
| 名前 | 説明 | 対応バージョン |
7878
|------|------|----------------|
79-
| [`submdspan_mapping`](mapping/submdspan_mapping.md.nolink) | [`submdspan`](../submdspan.md)サポート | C++26 |
79+
| [`submdspan_mapping`](mapping/submdspan_mapping.md) | [`submdspan`](../submdspan.md)サポート | C++26 |
8080
8181
### 比較演算子
8282
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# submdspan_mapping
2+
* mdspan[meta header]
3+
* function template[meta id-type]
4+
* std[meta namespace]
5+
* layout_left::mapping[meta class]
6+
* cpp23[meta cpp]
7+
8+
```cpp
9+
template<class... SliceSpecifiers>
10+
constexpr auto submdspan-mapping-impl( // exposition only
11+
SliceSpecifiers ... slices) const -> see below;
12+
13+
template<class... SliceSpecifiers>
14+
friend constexpr auto submdspan_mapping(
15+
const mapping& src, SliceSpecifiers... slices)
16+
{
17+
return src.submdspan-mapping-impl(slices...);
18+
}
19+
```
20+
* see below[italic]
21+
* submdspan-mapping-impl[italic]
22+
23+
## 概要
24+
[`submdspan`](../../submdspan.md)関数をサポートするためのカスタマイゼーションポイント。
25+
26+
説明用の型`index_type`を[`Extents::index_type`](../../extents.md)、型`S_k`を`SliceSpecifiers`の`k`番目の型とする。
27+
28+
29+
## テンプレートパラメータ制約
30+
`sizeof...(slices)`が[`Extents::rank()`](../../extents/rank.md)と等しいこと。
31+
32+
33+
## 適格要件
34+
`extents()`の各次元インデクス`k`において、下記いずれかのうち1つだけを満たすこと。
35+
36+
- 型`S_k`が[`convertible_to`](/reference/concepts/convertible_to.md)`<index_type>`のモデル
37+
- 型`S_k`が[`index-pair-like`](../../index-pair-like.md)`<index_type>`のモデル
38+
- [`is_convertible_v`](/reference/type_traits/is_convertible.md)`<S_k,` [`full_extent_t`](../../full_extent_t.md)`>`が`true`
39+
- 型`S_k`が[`strided_slice`](../../strided_slice.md)の特殊化
40+
41+
42+
## 事前条件
43+
`extents()`の各次元インデクス`k`において、`s_k`を`slices`の`k`番目の値としたとき、下記を全て満たすこと。
44+
45+
- 型`S_k`が[`strided_slice`](../../strided_slice.md)の特殊化のとき
46+
- `s_k.extent == 0`、または
47+
- `s_k.stride > 0`
48+
- `0` ≤ [`first_`](../../first_.md)`<index_type, k>(slices...)` ≤ [`last_`](../../last_.md)`<k>(extents(), slices...)` ≤ `extents().`[`extent(k)`](../../extents/extent.md)
49+
50+
51+
## 戻り値
52+
説明用の値や型を次の通り定義する。
53+
54+
- 値`sub_ext` : 式[`submdspan_extents`](../../submdspan_extents.md)`(extents(), slices...)`の結果
55+
- 型`SubExtents` : `decltype(sub_ext)`
56+
- 値`sub_strides` : `extents()`の各次元インデクス`k`において、[`map-rank[k]`](../../submdspan_extents.md)が[`dynamic_extent`](/reference/span/dynamic_extent.md)ではない`k`に対し`sub_strides[map-rank[k]]`が下記を満たす、[`array`](/reference/array/array.md)`<SubExtents::index_type,` [`SubExtents::rank()`](../../extents/rank.md)`>`型の配列値
57+
- 型`S_k`が[`strided_slice`](../../strided_slice.md)の特殊化かつ`s_k.stride < s_k.extent`の場合、[`stride(k)`](stride.md) `*` [`de-ice`](../../de-ice.md)`(s_k.stride)`
58+
- そうでなければ、[`stride(k)`](stride.md)
59+
- パラメータパック`P` : [`is_same_v`](/reference/type_traits/is_same.md)`<`[`make_index_sequence`](/reference/utility/make_index_sequence.md)`<rank()>,` [`index_sequence`](/reference/utility/index_sequence.md)`<P...>> == true`
60+
- 値`offset` : `size_t`型の値[`(*this)`](op_call.md)`(`[`first_`](../../first_.md)`<index_type, P>(slices...)...)`
61+
62+
説明専用の`submdspan-mapping-impl`関数テンプレートは下記の値を返す。
63+
64+
- [`Extents::rank()`](../../extents/rank.md) `== 0`のとき、[`submdspan_mapping_result`](../../submdspan_mapping_result.md)`{*this, 0}`
65+
- 以下を満たすとき、[`submdspan_mapping_result`](../../submdspan_mapping_result.md)`{`[`layout_left::mapping`](../../layout_left.md)`(sub_ext), offset}`
66+
- 半開区間`[0, SubExtents::rank()-1)`の値`k`に対して、[`is_convertible_v`](/reference/type_traits/is_convertible.md)`<S_k,` [`full_extent_t`](../../full_extent_t.md)`>`が`true`、かつ
67+
- `SubExtents::rank()-1`に等しい値`k`に対して、型`S_k`が[`index-pair-like`](../../index-pair-like.md)`<index_type>`のモデルもしくは[`is_convertible_v`](/reference/type_traits/is_convertible.md)`<S_k,` [`full_extent_t`](../../full_extent_t.md)`>`が`true`
68+
- [`submdspan_mapping_result`](../../submdspan_mapping_result.md)`{`[`layout_stride::mapping`](../../layout_stride.md)`(sub_ext, sub_strides), offset}`
69+
70+
71+
## バージョン
72+
### 言語
73+
- C++23
74+
75+
### 処理系
76+
- [Clang](/implementation.md#clang): ??
77+
- [GCC](/implementation.md#gcc): ??
78+
- [ICC](/implementation.md#icc): ??
79+
- [Visual C++](/implementation.md#visual_cpp): ??
80+
81+
82+
## 関連項目
83+
- [`submdspan`](../../submdspan.md)
84+
85+
86+
## 参照
87+
- [P2630R4 Submdspan](https://open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2630r4.html)

reference/mdspan/layout_right/mapping.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace std {
7676
7777
| 名前 | 説明 | 対応バージョン |
7878
|------|------|----------------|
79-
| [`submdspan_mapping`](mapping/submdspan_mapping.md.nolink) | [`submdspan`](../submdspan.md)サポート | C++26 |
79+
| [`submdspan_mapping`](mapping/submdspan_mapping.md) | [`submdspan`](../submdspan.md)サポート | C++26 |
8080
8181
### 比較演算子
8282
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# submdspan_mapping
2+
* mdspan[meta header]
3+
* function template[meta id-type]
4+
* std[meta namespace]
5+
* layout_right::mapping[meta class]
6+
* cpp23[meta cpp]
7+
8+
```cpp
9+
template<class... SliceSpecifiers>
10+
constexpr auto submdspan-mapping-impl( // exposition only
11+
SliceSpecifiers ... slices) const -> see below;
12+
13+
template<class... SliceSpecifiers>
14+
friend constexpr auto submdspan_mapping(
15+
const mapping& src, SliceSpecifiers... slices)
16+
{
17+
return src.submdspan-mapping-impl(slices...);
18+
}
19+
```
20+
* see below[italic]
21+
* submdspan-mapping-impl[italic]
22+
23+
## 概要
24+
[`submdspan`](../../submdspan.md)関数をサポートするためのカスタマイゼーションポイント。
25+
26+
説明用の型`index_type`を[`Extents::index_type`](../../extents.md)、型`S_k`を`SliceSpecifiers`の`k`番目の型とする。
27+
28+
29+
## テンプレートパラメータ制約
30+
`sizeof...(slices)`が[`Extents::rank()`](../../extents/rank.md)と等しいこと。
31+
32+
33+
## 適格要件
34+
`extents()`の各次元インデクス`k`において、下記いずれかのうち1つだけを満たすこと。
35+
36+
- 型`S_k`が[`convertible_to`](/reference/concepts/convertible_to.md)`<index_type>`のモデル
37+
- 型`S_k`が[`index-pair-like`](../../index-pair-like.md)`<index_type>`のモデル
38+
- [`is_convertible_v`](/reference/type_traits/is_convertible.md)`<S_k,` [`full_extent_t`](../../full_extent_t.md)`>`が`true`
39+
- 型`S_k`が[`strided_slice`](../../strided_slice.md)の特殊化
40+
41+
42+
## 事前条件
43+
`extents()`の各次元インデクス`k`において、`s_k`を`slices`の`k`番目の値としたとき、下記を全て満たすこと。
44+
45+
- 型`S_k`が[`strided_slice`](../../strided_slice.md)の特殊化のとき
46+
- `s_k.extent == 0`、または
47+
- `s_k.stride > 0`
48+
- `0` ≤ [`first_`](../../first_.md)`<index_type, k>(slices...)` ≤ [`last_`](../../last_.md)`<k>(extents(), slices...)` ≤ `extents().`[`extent(k)`](../../extents/extent.md)
49+
50+
51+
## 戻り値
52+
説明用の値や型を次の通り定義する。
53+
54+
- 値`sub_ext` : 式[`submdspan_extents`](../../submdspan_extents.md)`(extents(), slices...)`の結果
55+
- 型`SubExtents` : `decltype(sub_ext)`
56+
- 値`sub_strides` : `extents()`の各次元インデクス`k`において、[`map-rank[k]`](../../submdspan_extents.md)が[`dynamic_extent`](/reference/span/dynamic_extent.md)ではない`k`に対し`sub_strides[map-rank[k]]`が下記を満たす、[`array`](/reference/array/array.md)`<SubExtents::index_type,` [`SubExtents::rank()`](../../extents/rank.md)`>`型の配列値
57+
- 型`S_k`が[`strided_slice`](../../strided_slice.md)の特殊化かつ`s_k.stride < s_k.extent`の場合、[`stride(k)`](stride.md) `*` [`de-ice`](../../de-ice.md)`(s_k.stride)`
58+
- そうでなければ、[`stride(k)`](stride.md)
59+
- パラメータパック`P` : [`is_same_v`](/reference/type_traits/is_same.md)`<`[`make_index_sequence`](/reference/utility/make_index_sequence.md)`<rank()>,` [`index_sequence`](/reference/utility/index_sequence.md)`<P...>> == true`
60+
- 値`offset` : `size_t`型の値[`(*this)`](op_call.md)`(`[`first_`](../../first_.md)`<index_type, P>(slices...)...)`
61+
62+
説明専用の`submdspan-mapping-impl`関数テンプレートは下記の値を返す。
63+
64+
- [`Extents::rank()`](../../extents/rank.md) `== 0`のとき、[`submdspan_mapping_result`](../../submdspan_mapping_result.md)`{*this, 0}`
65+
- 以下を満たすとき、[`submdspan_mapping_result`](../../submdspan_mapping_result.md)`{`[`layout_right::mapping`](../../layout_right.md)`(sub_ext), offset}`
66+
- 半開区間`[Extents::rank() - SubExtents::rank()+1, Extents::rank())`の値`k`に対して、[`is_convertible_v`](/reference/type_traits/is_convertible.md)`<S_k,` [`full_extent_t`](../../full_extent_t.md)`>`が`true`、かつ
67+
- `Extents::rank()-SubExtents::rank()`に等しい値`k`に対して、型`S_k`が[`index-pair-like`](../../index-pair-like.md)`<index_type>`のモデルもしくは[`is_convertible_v`](/reference/type_traits/is_convertible.md)`<S_k,` [`full_extent_t`](../../full_extent_t.md)`>`が`true`
68+
- [`submdspan_mapping_result`](../../submdspan_mapping_result.md)`{`[`layout_stride::mapping`](../../layout_stride.md)`(sub_ext, sub_strides), offset}`
69+
70+
71+
## バージョン
72+
### 言語
73+
- C++23
74+
75+
### 処理系
76+
- [Clang](/implementation.md#clang): ??
77+
- [GCC](/implementation.md#gcc): ??
78+
- [ICC](/implementation.md#icc): ??
79+
- [Visual C++](/implementation.md#visual_cpp): ??
80+
81+
82+
## 関連項目
83+
- [`submdspan`](../../submdspan.md)
84+
85+
86+
## 参照
87+
- [P2630R4 Submdspan](https://open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2630r4.html)

reference/mdspan/layout_stride/mapping.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ namespace std {
7878
7979
| 名前 | 説明 | 対応バージョン |
8080
|------|------|----------------|
81-
| [`submdspan_mapping`](mapping/submdspan_mapping.md.nolink) | [`submdspan`](../submdspan.md)サポート | C++26 |
81+
| [`submdspan_mapping`](mapping/submdspan_mapping.md) | [`submdspan`](../submdspan.md)サポート | C++26 |
8282
8383
### 比較演算子
8484
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# submdspan_mapping
2+
* mdspan[meta header]
3+
* function template[meta id-type]
4+
* std[meta namespace]
5+
* layout_stride::mapping[meta class]
6+
* cpp23[meta cpp]
7+
8+
```cpp
9+
template<class... SliceSpecifiers>
10+
constexpr auto submdspan-mapping-impl( // exposition only
11+
SliceSpecifiers ... slices) const -> see below;
12+
13+
template<class... SliceSpecifiers>
14+
friend constexpr auto submdspan_mapping(
15+
const mapping& src, SliceSpecifiers... slices)
16+
{
17+
return src.submdspan-mapping-impl(slices...);
18+
}
19+
```
20+
* see below[italic]
21+
* submdspan-mapping-impl[italic]
22+
23+
## 概要
24+
[`submdspan`](../../submdspan.md)関数をサポートするためのカスタマイゼーションポイント。
25+
26+
説明用の型`index_type`を[`Extents::index_type`](../../extents.md)、型`S_k`を`SliceSpecifiers`の`k`番目の型とする。
27+
28+
29+
## テンプレートパラメータ制約
30+
`sizeof...(slices)`が[`Extents::rank()`](../../extents/rank.md)と等しいこと。
31+
32+
33+
## 適格要件
34+
`extents()`の各次元インデクス`k`において、下記いずれかのうち1つだけを満たすこと。
35+
36+
- 型`S_k`が[`convertible_to`](/reference/concepts/convertible_to.md)`<index_type>`のモデル
37+
- 型`S_k`が[`index-pair-like`](../../index-pair-like.md)`<index_type>`のモデル
38+
- [`is_convertible_v`](/reference/type_traits/is_convertible.md)`<S_k,` [`full_extent_t`](../../full_extent_t.md)`>`が`true`
39+
- 型`S_k`が[`strided_slice`](../../strided_slice.md)の特殊化
40+
41+
42+
## 事前条件
43+
`extents()`の各次元インデクス`k`において、`s_k`を`slices`の`k`番目の値としたとき、下記を全て満たすこと。
44+
45+
- 型`S_k`が[`strided_slice`](../../strided_slice.md)の特殊化のとき
46+
- `s_k.extent == 0`、または
47+
- `s_k.stride > 0`
48+
- `0` ≤ [`first_`](../../first_.md)`<index_type, k>(slices...)` ≤ [`last_`](../../last_.md)`<k>(extents(), slices...)` ≤ `extents().`[`extent(k)`](../../extents/extent.md)
49+
50+
51+
## 戻り値
52+
説明用の値や型を次の通り定義する。
53+
54+
- 値`sub_ext` : 式[`submdspan_extents`](../../submdspan_extents.md)`(extents(), slices...)`の結果
55+
- 型`SubExtents` : `decltype(sub_ext)`
56+
- 値`sub_strides` : `extents()`の各次元インデクス`k`において、[`map-rank[k]`](../../submdspan_extents.md)が[`dynamic_extent`](/reference/span/dynamic_extent.md)ではない`k`に対し`sub_strides[map-rank[k]]`が下記を満たす、[`array`](/reference/array/array.md)`<SubExtents::index_type,` [`SubExtents::rank()`](../../extents/rank.md)`>`型の配列値
57+
- 型`S_k`が[`strided_slice`](../../strided_slice.md)の特殊化かつ`s_k.stride < s_k.extent`の場合、[`stride(k)`](stride.md) `*` [`de-ice`](../../de-ice.md)`(s_k.stride)`
58+
- そうでなければ、[`stride(k)`](stride.md)
59+
- パラメータパック`P` : [`is_same_v`](/reference/type_traits/is_same.md)`<`[`make_index_sequence`](/reference/utility/make_index_sequence.md)`<rank()>,` [`index_sequence`](/reference/utility/index_sequence.md)`<P...>> == true`
60+
- 値`offset` : `size_t`型の値[`(*this)`](op_call.md)`(`[`first_`](../../first_.md)`<index_type, P>(slices...)...)`
61+
62+
説明専用の`submdspan-mapping-impl`関数テンプレートは下記の値を返す。
63+
64+
- [`Extents::rank()`](../../extents/rank.md) `== 0`のとき、[`submdspan_mapping_result`](../../submdspan_mapping_result.md)`{*this, 0}`
65+
- [`submdspan_mapping_result`](../../submdspan_mapping_result.md)`{`[`layout_stride::mapping`](../../layout_stride.md)`(sub_ext, sub_strides), offset}`
66+
67+
68+
## バージョン
69+
### 言語
70+
- C++23
71+
72+
### 処理系
73+
- [Clang](/implementation.md#clang): ??
74+
- [GCC](/implementation.md#gcc): ??
75+
- [ICC](/implementation.md#icc): ??
76+
- [Visual C++](/implementation.md#visual_cpp): ??
77+
78+
79+
## 関連項目
80+
- [`submdspan`](../../submdspan.md)
81+
82+
83+
## 参照
84+
- [P2630R4 Submdspan](https://open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2630r4.html)

reference/mdspan/submdspan.md

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ namespace std {
3535
- ストライド・スライス指定 : [`std::strided_slice`](strided_slice.md)の値。オフセット(offset)と要素数(extent)とストライド幅(stride)で指定される要素群を取り出す。
3636
- 全要素指定 : [`std::full_extent`](full_extent_t.md)。指定次元の全要素を取り出す。
3737
38+
### カスタマイゼーションポイント
39+
`submdspan`関数により[`mdspan`](mdspan.md)から部分ビューを取り出すには、変換元の[レイアウトマッピング型](LayoutMapping.md)がカスタマイゼーションポイント`submdspan_mapping`を実装している必要がある。
40+
3841
3942
## テンプレートパラメータ制約
4043
- `sizeof...(slices)`が[`Extents::rank()`](extents/rank.md)と等しく、かつ

reference/mdspan/submdspan_extents.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ namespace std {
1515
## 概要
1616
多次元配列サイズ[`extents`](extents.md)と各次元からの要素取り出し(スライス)方式を指定して、新しい多次元配列サイズ[`extents`](extents.md)を取得する。
1717
18+
各次元からの要素取り出し方式は、[`submdspan`](submdspan.md)を参照のこと。
19+
1820
### 動作説明用
1921
- 型`S_k` : `SliceSpecifiers`の`k`番目の型
2022
- 値`s_k` : `slices`の`k`番目の値

reference/mdspan/submdspan_mapping_result.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace std {
1717
* no_unique_address[link /lang/cpp20/language_support_for_empty_objects.md]
1818
1919
## 概要
20-
`submdspan_mapping_result`は、多次元配列ビュー[mdspan](mdspan.md)からの部分ビュー[`submdspan`](submdspan.md)取り出しサポートのために定義するカスタマイズポイント`submdspan_mapping`の戻り値型である。
20+
`submdspan_mapping_result`は、多次元配列ビュー[mdspan](mdspan.md)からの部分ビュー[`submdspan`](submdspan.md)取り出しサポートのために定義するカスタマイゼーションポイント`submdspan_mapping`の戻り値型である。
2121
2222
- `mapping` : 多次元配列部分ビューの[レイアウトマッピング](LayoutMapping.md)
2323
- `offset` : 多次元配列部分ビューの要素オフセット位置

0 commit comments

Comments
 (0)