From Jason Turner

[mdspan.layout.right]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpbgf00d7z/{from.md → to.md} +187 -0
tmp/tmpbgf00d7z/{from.md → to.md} RENAMED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##### Class template `layout_right::mapping` <a id="mdspan.layout.right">[[mdspan.layout.right]]</a>
2
+
3
+ ###### Overview <a id="mdspan.layout.right.overview">[[mdspan.layout.right.overview]]</a>
4
+
5
+ `layout_right` provides a layout mapping where the rightmost extent is
6
+ stride 1, and strides increase right-to-left as the product of extents.
7
+
8
+ ``` cpp
9
+ namespace std {
10
+ template<class Extents>
11
+ class layout_right::mapping {
12
+ public:
13
+ using extents_type = Extents;
14
+ using index_type = typename extents_type::index_type;
15
+ using size_type = typename extents_type::size_type;
16
+ using rank_type = typename extents_type::rank_type;
17
+ using layout_type = layout_right;
18
+
19
+ // [mdspan.layout.right.cons], constructors
20
+ constexpr mapping() noexcept = default;
21
+ constexpr mapping(const mapping&) noexcept = default;
22
+ constexpr mapping(const extents_type&) noexcept;
23
+ template<class OtherExtents>
24
+ constexpr explicit(!is_convertible_v<OtherExtents, extents_type>)
25
+ mapping(const mapping<OtherExtents>&) noexcept;
26
+ template<class OtherExtents>
27
+ constexpr explicit(!is_convertible_v<OtherExtents, extents_type>)
28
+ mapping(const layout_left::mapping<OtherExtents>&) noexcept;
29
+ template<class OtherExtents>
30
+ constexpr explicit(extents_type::rank() > 0)
31
+ mapping(const layout_stride::mapping<OtherExtents>&) noexcept;
32
+
33
+ constexpr mapping& operator=(const mapping&) noexcept = default;
34
+
35
+ // [mdspan.layout.right.obs], observers
36
+ constexpr const extents_type& extents() const noexcept { return extents_; }
37
+
38
+ constexpr index_type required_span_size() const noexcept;
39
+
40
+ template<class... Indices>
41
+ constexpr index_type operator()(Indices...) const noexcept;
42
+
43
+ static constexpr bool is_always_unique() noexcept { return true; }
44
+ static constexpr bool is_always_exhaustive() noexcept { return true; }
45
+ static constexpr bool is_always_strided() noexcept { return true; }
46
+
47
+ static constexpr bool is_unique() noexcept { return true; }
48
+ static constexpr bool is_exhaustive() noexcept { return true; }
49
+ static constexpr bool is_strided() noexcept { return true; }
50
+
51
+ constexpr index_type stride(rank_type) const noexcept;
52
+
53
+ template<class OtherExtents>
54
+ friend constexpr bool operator==(const mapping&, const mapping<OtherExtents>&) noexcept;
55
+
56
+ private:
57
+ extents_type extents_{}; // exposition only
58
+ };
59
+ }
60
+ ```
61
+
62
+ If `Extents` is not a specialization of `extents`, then the program is
63
+ ill-formed.
64
+
65
+ `layout_right::mapping<E>` is a trivially copyable type that models
66
+ `regular` for each `E`.
67
+
68
+ *Mandates:* If `Extents::rank_dynamic() == 0` is `true`, then the size
69
+ of the multidimensional index space `Extents()` is representable as a
70
+ value of type `typename Extents::index_type`.
71
+
72
+ ###### Constructors <a id="mdspan.layout.right.cons">[[mdspan.layout.right.cons]]</a>
73
+
74
+ ``` cpp
75
+ constexpr mapping(const extents_type& e) noexcept;
76
+ ```
77
+
78
+ *Preconditions:* The size of the multidimensional index space `e` is
79
+ representable as a value of type `index_type` [[basic.fundamental]].
80
+
81
+ *Effects:* Direct-non-list-initializes *extents\_* with `e`.
82
+
83
+ ``` cpp
84
+ template<class OtherExtents>
85
+ constexpr explicit(!is_convertible_v<OtherExtents, extents_type>)
86
+ mapping(const mapping<OtherExtents>& other) noexcept;
87
+ ```
88
+
89
+ *Constraints:* `is_constructible_v<extents_type, OtherExtents>` is
90
+ `true`.
91
+
92
+ *Preconditions:* `other.required_span_size()` is representable as a
93
+ value of type `index_type` [[basic.fundamental]].
94
+
95
+ *Effects:* Direct-non-list-initializes *extents\_* with
96
+ `other.extents()`.
97
+
98
+ ``` cpp
99
+ template<class OtherExtents>
100
+ constexpr explicit(!is_convertible_v<OtherExtents, extents_type>)
101
+ mapping(const layout_left::mapping<OtherExtents>& other) noexcept;
102
+ ```
103
+
104
+ *Constraints:*
105
+
106
+ - `extents_type::rank() <= 1` is `true`, and
107
+ - `is_constructible_v<extents_type, OtherExtents>` is `true`.
108
+
109
+ *Preconditions:* `other.required_span_size()` is representable as a
110
+ value of type `index_type` [[basic.fundamental]].
111
+
112
+ *Effects:* Direct-non-list-initializes *extents\_* with
113
+ `other.extents()`.
114
+
115
+ ``` cpp
116
+ template<class OtherExtents>
117
+ constexpr explicit(extents_type::rank() > 0)
118
+ mapping(const layout_stride::mapping<OtherExtents>& other) noexcept;
119
+ ```
120
+
121
+ *Constraints:* `is_constructible_v<extents_type, OtherExtents>` is
122
+ `true`.
123
+
124
+ *Preconditions:*
125
+
126
+ - If `extents_type::rank() > 0` is `true`, then for all r in the range
127
+ [0, `extents_type::rank()`), `other.stride(`r`)` equals
128
+ `other.extents().`*`rev-prod-of-extents`*`(`r`)`.
129
+ - `other.required_span_size()` is representable as a value of type
130
+ `index_type` [[basic.fundamental]].
131
+
132
+ *Effects:* Direct-non-list-initializes *extents\_* with
133
+ `other.extents()`.
134
+
135
+ ###### Observers <a id="mdspan.layout.right.obs">[[mdspan.layout.right.obs]]</a>
136
+
137
+ ``` cpp
138
+ index_type required_span_size() const noexcept;
139
+ ```
140
+
141
+ *Returns:* `extents().`*`fwd-prod-of-extents`*`(extents_type::rank())`.
142
+
143
+ ``` cpp
144
+ template<class... Indices>
145
+ constexpr index_type operator()(Indices... i) const noexcept;
146
+ ```
147
+
148
+ *Constraints:*
149
+
150
+ - `sizeof...(Indices) == extents_type::rank()` is `true`,
151
+ - `(is_convertible_v<Indices, index_type> && ...)` is `true`, and
152
+ - `(is_nothrow_constructible_v<index_type, Indices> && ...)` is `true`.
153
+
154
+ *Preconditions:* `extents_type::`*`index-cast`*`(i)` is a
155
+ multidimensional index in *extents\_*[[mdspan.overview]].
156
+
157
+ *Effects:* Let `P` be a parameter pack such that
158
+
159
+ ``` cpp
160
+ is_same_v<index_sequence_for<Indices...>, index_sequence<P...>>
161
+ ```
162
+
163
+ is `true`. Equivalent to:
164
+
165
+ ``` cpp
166
+ return ((static_cast<index_type>(i) * stride(P)) + ... + 0);
167
+ ```
168
+
169
+ ``` cpp
170
+ constexpr index_type stride(rank_type i) const noexcept;
171
+ ```
172
+
173
+ *Constraints:* `extents_type::rank() > 0` is `true`.
174
+
175
+ *Preconditions:* `i < extents_type::rank()` is `true`.
176
+
177
+ *Returns:* `extents().`*`rev-prod-of-extents`*`(i)`.
178
+
179
+ ``` cpp
180
+ template<class OtherExtents>
181
+ friend constexpr bool operator==(const mapping& x, const mapping<OtherExtents>& y) noexcept;
182
+ ```
183
+
184
+ *Constraints:* `extents_type::rank() == OtherExtents::rank()` is `true`.
185
+
186
+ *Effects:* Equivalent to: `return x.extents() == y.extents();`
187
+