-
Notifications
You must be signed in to change notification settings - Fork 9
/
P0454r0.bs
877 lines (630 loc) · 27.4 KB
/
P0454r0.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
<pre class='metadata'>
Title: Wording for a Minimal mdspan<>
Abstract: Proposed wording, based on span [[P0122R3]] for an <code>mdspan</code> with a core subset of the full <code>mdspan</code> functionality.
Shortname: P0454
Revision: 0
Audience: LEWG, LWG
Status: D
Group: WG21
URL: http://wg21.link/P0454r0
Editor: H. Carter Edwards, Sandia National Laboratory, hcedwar@sandia.gov
Editor: Bryce Adelstein Lelbach, Lawrence Berkeley National Laboratory, balelbach@lbl.gov
Date: 2016-10-10
Markup Shorthands: markdown yes
Warning: Custom
Custom Warning Title: Withdrawn
Custom Warning Text: This document has been withdrawn and is no longer applicable.
</pre>
Modified P0122R3 Wording {#spanword}
==========
The proposed changes are relative to the working draft of the standard
as of [[N4567]] with the changes proposed in [[P0122R3]] applied.
The � character is used to denote a placeholder section number which the editor
shall determine.
Apply the following changes to 23.7.� [views.general] paragraph 1:
<blockquote>
The header `<span>` defines the <del>view</del><ins>views</ins> `span`
<ins>and `mdspan`</ins>. A `span` is a view over a
contiguous sequence of objects, the storage of which is owned by some other
object.<ins> An `mdspan` is a multidimensional view over a contiguous sequence
of objects, the storage of which is owned by some other object.</ins>
</blockquote>
Apply the following changes to 23.7.�.1 [views.span.synop]:
<pre>
namespace std {
// [views.constants], constants
<del>constexpr ptrdiff_t dynamic_extent = -1;</del>
<ins>enum class dynamic_extent_tag {};
inline constexpr dynamic_extent_tag dyn { -1 };
template <auto Extent>
using is_dynamic_dimension = typename is_same<decay_t<decltype(Extent)>,
dynamic_extent_tag>::type;
template <auto Extent>
inline constexpr bool is_dynamic_dimension_v =
is_dynamic_dimension<Extent>::value;</ins>
// [views.span], class template span
template <class ElementType, <del>ptrdiff_t</del><ins>auto</ins> Extent = <del>dynamic_extent</del><ins>dyn</ins>>
class span;
// [views.span.comparison], span comparison operators
template <class ElementType, <del>ptrdiff_t</del><ins>auto</ins> Extent>
constexpr bool operator==(const span<ElementType, Extent>& l, const
span<ElementType, Extent>& r);
template <class ElementType, <del>ptrdiff_t</del><ins>auto</ins> Extent>
constexpr bool operator!=(const span<ElementType, Extent>& l, const
span<ElementType, Extent>& r);
template <class ElementType, <del>ptrdiff_t</del><ins>auto</ins> Extent>
constexpr bool operator<(const span<ElementType, Extent>& l, const
span<ElementType, Extent>& r);
template <class ElementType, <del>ptrdiff_t</del><ins>auto</ins> Extent>
constexpr bool operator<=(const span<ElementType, Extent>& l, const
span<ElementType, Extent>& r);
template <class ElementType, <del>ptrdiff_t</del><ins>auto</ins> Extent>
constexpr bool operator>(const span<ElementType, Extent>& l, const
span<ElementType, Extent>& r);
template <class ElementType, <del>ptrdiff_t</del><ins>auto</ins> Extent>
constexpr bool operator>=(const span<ElementType, Extent>& l, const
span<ElementType, Extent>& r);
// [views.span.objectrep], views of object representation
template <class ElementType, <del>ptrdiff_t</del><ins>auto</ins> Extent>
span<const char, ((<del>Extent == dynamic_extent</del><ins>is_dynamic_dimension_v<Extent></ins>) ? dynamic_extent :
(sizeof(ElementType) * Extent))> as_bytes(span<ElementType, Extent> s)
noexcept;
template <class ElementType, <del>ptrdiff_t</del><ins>auto</ins> Extent>
span<const char, ((<del>Extent == dynamic_extent</del><ins>is_dynamic_dimension_v<Extent></ins>) ? dynamic_extent :
(sizeof(ElementType) * Extent))> as_writeable_bytes(span<ElementType,
Extent>) noexcept;
<ins>// [views.dimensions], class template dimensions
template <auto... Extents>
class dimensions;
// [views.dimensions.comparison], dimensions comparison operators
template <auto... Extents>
constexpr bool operator==(const dimensions<Extents...>& l,
const dimensions<Extents...>& r);
template <auto... Extents>
constexpr bool operator!=(const dimensions<Extents...>& l,
const dimensions<Extents...>& r);
// [views.mdspan], class template mdspan
template <class ElementType, class Dimensions, class... Properties>
class mdspan;
template <class T> struct is_mdspan_property;
template <class T>
inline constexpr bool is_mdspan_property_v = is_mdspan_property<T>::value;
// [views.layout.props], mdspan layout properties
class layout_right;
class layout_left;
<!--
class layout_stride;
-->
template <class T> struct is_layout;
template <class T>
inline constexpr bool is_layout_v = is_layout<T>::value;
<!--
// [views.mdspan.subspan], mdspan slicing support
struct all_extent_tag { };
inline constexpr all_extent_tag all { };</ins>
-->
} // namespace std
</pre>
Add the following paragraph in between paragraphs 2 and 3 in 23.7.�.2 [views.span.template]:
<blockquote>
<ins>`span` requires the type of `Extent` to be either `dynamic_extent_tag` or
implicitly convertible to the `span`'s `index_type`.</ins>
</blockquote>
Apply the following changes to the definition of `span` in 23.7.�.2 [views.span.template]
<pre>
namespace std {
// A view over a contiguous, single-dimension sequence of objects
template <class ElementType, <del>ptrdiff_t</del><ins>auto</ins> Extent = <del>dynamic_extent</del><ins>dyn</ins>>
class span {
</pre>
<pre>
<ins>inline</ins> constexpr <del>static index_type</del><ins>auto</ins> extent = Extent;
</pre>
<pre>
template <class OtherElementType, <del>ptrdiff_t</del><ins>auto</ins> OtherExtent>
constexpr span(const span<OtherElementType, OtherExtent>& other);
template <class OtherElementType, <del>ptrdiff_t</del><ins>auto</ins> OtherExtent>
constexpr span(span<OtherElementType, OtherExtent>&& other);
</pre>
<pre>
template <ptrdiff_t Offset, <del>ptrdiff_t</del><ins>auto</ins> Count = <del>dynamic_extent</del><ins>dyn</ins>>
constexpr span<element_type, Count> subspan() const;
constexpr span<element_type, dynamic_extent> first(index_type count) const;
constexpr span<element_type, dynamic_extent> last(index_type count) const;
<ins> constexpr span<element_type, dynamic_extent> subspan(index_type
offset) const;</ins>
constexpr span<element_type, dynamic_extent> subspan(index_type
offset, index_type count<del> = dynamic_extent</del>) const;
</pre>
Apply the following changes to the converting copy constructor in 23.7.�.3
[views.span.cons]:
<blockquote>
<pre>
template <class OtherElementType, <del>ptrdiff_t</del><ins>auto</ins> OtherExtent>
constexpr span(const span<OtherElementType, OtherExtent>& other);
template <class OtherElementType, <del>ptrdiff_t</del><ins>auto</ins> OtherExtent>
constexpr span(span<OtherElementType, OtherExtent>&& other);
</pre>
*Remarks:* These constructors shall not participate in overload resolution
unless trying to access OtherElementType through an ElementType* would meet the
rules for well-defined object access defined in 3.10/10.
*Requires:* If <del>`extent` is not equal to `dynamic_extent`</del><ins>`is_dynamic_dimension_v<Extent> == false`</ins>,
then `other.size()` shall be equal to `extent`.
*Effects:* Constructs a `span` by copying the implementation data members of
another `span`, performing suitable conversions.
*Postconditions:* `size() == other.size() && data() == reinterpret_cast<pointer>(other.data())`.
*Complexity:* Constant.
*Throws:* Nothing.
</blockquote>
Apply the following changes to `subspan()` in 23.7.�.4 [views.span.sub]:
<blockquote>
<pre>
template <ptrdiff_t Offset, <del>ptrdiff_t</del><ins>auto</ins> Count = <del>dynamic_extent</del><ins>dyn</ins>>
constexpr span<element_type, Count> subspan() const;
</pre>
*Requires:* <code>(Offset == 0 || Offset > 0 && Offset < size()) &&
(<del>Count == dynamic_extent</del><ins>is_dynamic_dimension<Count></ins> || Count >= 0 && Offset + Count <= size())</code>.
*Effects:* Returns a new `span` that is a view over `Count` elements of the
current span starting at element `Offset`. If <del>`Count` is equal to
`dynamic_extent`</del><ins>`is_dynamic_dimension<Count> == true`</ins>, then a `span` over all elements from `Offset` onwards is
returned.
*Returns:* <code>span(data() + Offset, <del>Count == dynamic_extent</del><ins>is_dynamic_dimension<Count></ins> ? size() - Offset : Count)</code>.
*Complexity:* Constant.
</blockquote>
Add the following `subspan()` overload to 23.7.�.4 [views.span.sub]:
<blockquote>
<ins style="display: block;">
<pre>
constexpr span<element_type, dynamic_extent> subspan(index_type
offset) const;
</pre>
*Requires:* `(offset == 0 || offset > 0 && offset < size())`.
*Effects:* Returns a new `span` that is a view over all elements from `offset`
onwards.
*Returns:* `span(data() + offset, size() - offset)`.
*Complexity:* Constant.
</ins>
</blockquote>
Apply the following changes to `subspan()` in 23.7.�.4 [views.span.sub]:
<blockquote>
<pre>
constexpr span<element_type, dynamic_extent> subspan(index_type
offset, index_type count<del> = dynamic_extent</del>) const;
</pre>
*Requires:* <code>(offset == 0 || offset > 0 && offset < size()) &&
(<del>count == dynamic_extent || </del>count >= 0 && offset + count <= size())</code>.
*Effects:* Returns a new `span` that is a view over `count` elements of the
current span starting at element `offset`.<del> If count is equal to
`dynamic_extent`, then a `span` over all elements from `offset` onwards is
returned.</del>
*Returns:* <code>span(data() + offset, <del>count == dynamic_extent ? size() - offset : </del>count)</code>.
*Complexity:* Constant.
</blockquote>
`mdspan` Wording {#mdspanword}
================
`dimensions` Class Template {#dims}
----------------
Add the following section, 23.7.� [views.dimensions.template]:
<blockquote>
<ins style="display: block;">
**23.7.� Class Template** `dimensions` **[views.dimensions.template]**
<pre>
template <auto... Extents>
class dimensions {
public:
// types
using value_type = ptrdiff_t;
using index_type = ptrdiff_t;
// [views.dimensions.cons], constructors/assignment/destructor
constexpr dimensions() noexcept;
template <class... DynamicExtents>
constexpr dimensions(DynamicExtents... dexts) noexcept;
constexpr dimensions(dimensions const& other) noexcept = default;
constexpr dimensions(dimensions&& other) noexcept = default;
dimensions& operator=(dimensions const& other) noexcept = default;
dimensions& operator=(dimensions&& other) noexcept = default;
// [views.dimensions.obs], observers
static constexpr index_type rank() noexcept;
static constexpr index_type rank_dynamic() noexcept;
constexpr size_type size() noexcept;
constexpr bool is_dynamic_dimension(index_type i) const noexcept;
// [views.dimensions.elem], element access
constexpr value_type operator[](index_type i) const noexcept;
};
</pre>
`dimensions` is a class which contains storage for a fixed number of integer
elements, each of which represents the extent of a *dimension*, collectively
forming a multi-dimensional integer index.
Each non-type template parameter specifies either a positive integral value,
indicating a *static dimension*, or a value of type `dynamic_extent_tag`,
indicating a *dynamic dimension* whose value will be provided at runtime.
Implementations are not permitted to use additional storage, such as dynamic
memory, to allocate the contained dimensions. The contained values shall be
allocated in a region of the `dimensions` storage suitably aligned for the type
`value_type`. [ *Note:* Implementations are not required to store the value
of static dimensions. — *end note* ]
</ins>
</blockquote>
Add the following section, 23.7.� [views.dimensions.cons]:
<blockquote>
<ins style="display: block;">
**23.7.�** `dimensions` **Constructors, Assignment and Destructors [views.dimensions.cons]**
<pre>
constexpr dimensions() noexcept;
</pre>
*Effects:* Constructs a `dimensions` object with all dynamic dimensions default
initialized.
<pre>
template <class... DynamicExtents>
constexpr dimensions(DynamicExtents... dexts) noexcept;
</pre>
*Remarks:* This constructor shall not participate in overload resolution unless
`sizeof...(DynamicExtents) == rank_dynamic()`.
*Effects:* Constructs a `dimensions` object with each dynamic dimensions
initialized from a corresponding value in `dexts`.
<!--
[ *Example:*
TODO
— *end example* ]
-->
<pre>
constexpr dimensions(dimensions const& other) noexcept = default;
constexpr dimensions(dimensions&& other) noexcept = default;
</pre>
*Effects:* Constructs a `dimensions` object by copying from another
`dimensions` object.
<pre>
dimensions& operator=(dimensions const& other) noexcept = default;
dimensions& operator=(dimensions&& other) noexcept = default;
</pre>
*Effects:* Assigns from one `dimensions` object into another.
</ins>
</blockquote>
Add the following section, 23.7.� [views.dimensions.obs]:
<blockquote>
<ins style="display: block;">
**23.7.�** `dimensions` **Observers [views.dimensions.obs]**
<pre>
static constexpr index_type rank() noexcept;
</pre>
*Effects:* Returns the number of elements in the `dimensions` object.
*Returns:* `sizeof...(Extents)`.
<pre>
static constexpr index_type rank() noexcept;
</pre>
*Effects:* Returns the number of parameters in `Extents` for which
`is_dynamic_dimension_v` is `true`.
<pre>
constexpr bool is_dynamic_dimension(index_type i) const noexcept;
</pre>
*Effects:* If `i < rank()`, returns true if the `i`th dimension is a dynamic
dimension. Otherwise, returns false.
</ins>
</blockquote>
Add the following section, 23.7.� [views.dimensions.elem]:
<blockquote>
<ins style="display: block;">
**23.7.�** `dimensions` **Element Access [views.dimensions.elem]**
<pre>
constexpr value_type operator[](index_type i) const noexcept;
</pre>
*Effects:* If `i < rank()`, returns the value of the `i`th element. Otherwise,
returns 0.
</ins>
</blockquote>
Add the following section, 23.7.� [views.dimensions.comparison]:
<blockquote>
<ins style="display: block;">
**23.7.�** `dimensions` **Comparison Operators [views.dimensions.comparison]**
<pre>
template <auto... Extents>
constexpr bool operator==(const dimensions<Extents...>& l,
const dimensions<Extents...>& r);
</pre>
*Effects:* `l[i] == r[i]`, where `i` is in the range `[0, rank())`.
*Throws:* Nothing.
<pre>
template <auto... Extents>
constexpr bool operator!=(const dimensions<Extents...>& l,
const dimensions<Extents...>& r);
</pre>
*Effects:* Equivalent to `return !(l == r);`
</ins>
</blockquote>
Layout Mapping Requirements {#layreq}
----------------
Add the following section, 23.7.� [views.layout.requirements]:
<blockquote>
<ins style="display: block;">
**23.7.� Layout Mapping Requirements [views.layout.requirements]**
A *layout* is class that describes a mapping from a multi-dimensional index to
a *mapped index*, which is one-dimensional. `mdspan` (23.7.�) is parameterized
in terms of layout mappings.
A layout shall have an embedded template class `mapping` which takes a single
template parameter that shall be a type which fulfills the definition of
the `dimensions` class. *Layout mappings* are instantiations of this embedded
template class.
In the following section:
- Let `LM` be a layout mapping and let `lm` be an object of type `LM`.
- Let `i` be in the range `[0, rank())` in order.
The expression `is_layout<LM>::value` shall be true.
The expression `lm.span()` shall be well-formed and have the following
semantics:
- *Effects:* Returns `(*this)(extent(0), /* ... */, extent(i)) - (*this)(0, /* ... */, 0)`.
The expression `LM::is_always_strided(r)` shall be true if the difference
between two mapped indices that are consecutive is always identical.
If `LM::is_always_strided(r)`, the expression `lm.stride(r)` shall be
well-formed and have the following semantics:
- *Effects:* Returns the difference between two mapped indices that are
consecutive.
The expression `lm(is...)` shall be well-formed and have the following semantics
if `sizeof...(decltype(is)) == LM::rank()` and all the types in `decltype(is)`
are integral:
- *Effects:* Returns the mapped index for multi-dimensional index `is`.
</ins>
</blockquote>
`mdspan` Class Template {#mdspan}
----------------
Add the following section, 23.7.� [views.mdspan.template]:
<blockquote>
<ins style="display: block;">
**23.7.� Class template** `mdspan` **[views.mdspan.template]**
<pre>
template <class ElementType, class Dimensions, class... Properties>
class mdspan {
public:
// types
using element_type = ElementType;
using index_type = ptrdiff_t;
using difference_type = ptrdiff_t;
using pointer = element_type*;
using reference = element_type&;
using layout = <i>implementation defined</i>;
using layout_mapping = typename layout::template mapping<Dimensions>;
// [views.mdspan.cons], constructors/assignment/destructor
constexpr mdspan() noexcept;
constexpr mdspan(nullptr_t) noexcept;
template <class... DynamicExtents>
constexpr mdspan(pointer ptr, DynamicExtents... dexts);
constexpr mdspan(pointer ptr, layout_mapping&& l);
constexpr mdspan(pointer ptr, layout_mapping const& l);
constexpr mdspan(mdspan const& other) noexcept = default;
constexpr mdspan(mdspan&& other) noexcept = default;
template <class UElementType, class UDimensions, class... UProperties>
constexpr mdspan(mdspan<UElementType, UDimensions, UProperties...> const& other);
template <class UElementType, class UDimensions, class... UProperties>
constexpr mdspan(mdspan<UElementType, UDimensions, UProperties...>&& other);
mdspan& operator=(mdspan const& other) noexcept = default;
mdspan& operator=(mdspan&& other) noexcept = default;
template <class UElementType, class UDimensions, class... UProperties>
mdspan& operator=(mdspan<UElementType, UDimensions, UProperties...> const& other);
template <class UElementType, class UDimensions, class... UProperties>
mdspan& operator=(mdspan<UElementType, UDimensions, UProperties...>&& other);
~mdspan() noexcept = default;
<!--
// [views.mdspan.sub], subviews
template <class... SliceSpecifiers>
<i>see-below</i> subarray(SliceSpecifiers&&... ss);
-->
// [views.mdspan.domobs], domain observers
static constexpr index_type rank() noexcept;
static constexpr index_type rank_dynamic() noexcept;
constexpr bool is_dynamic_dimension(rank_type r) const noexcept;
constexpr index_type extent(rank_type r) const noexcept;
constexpr index_type size() const noexcept;
constexpr index_type length() const noexcept;
constexpr bool empty() const noexcept;
// [views.mdspan.codobs], codomain observers
constexpr index_type span() const noexcept;
// [views.mdspan.mapobs], mapping observers
constexpr index_type stride(rank_type r) const noexcept;
constexpr layout_mapping mapping() const noexcept;
// [views.mdspan.elem], element access
template <class... Indices>
reference operator()(Indices... is) const;
constexpr pointer data() const noexcept;
};
</pre>
1. An `mdspan` is a multidimensional view over a contiguous sequence of
objects, the storage of which is owned by some other object.
2. `ElementType` is required to be a complete object that is not an abstract
class type.
3. In the following section:
- Let `i` be in the range `[0, sizeof...(Properties))` in order and
- <code>P<sup>i</sup></code> be the `i`th type in `Properties`,
- Let `r` be in the range `[0, rank())` in order and
- <code>Idx<sup>r</sup></code> be the `r`th type in a template parameter
pack named `Indices`,
- Let `rd` be in the range `[0, rank_dynamic())` in order, and
- <code>DExt<sup>rd</sup></code> be the `rd`th type in a template
parameter pack named `DynamicExtents`.
4. <code>is_layout_v<P<sup>i</sup>></code> shall be true for `i`. The
`layout` type is the type in <code>P<sup>i</sup></code> for which
<code>is_layout_v<P<sup>i</sup>> == true</code>. If
`sizeof...(Properties) == 0` or
<code>is_layout_v<P<sup>i</sup>> == false</code>
for all `i`, then the `layout` type is `layout_right`.
5. If <code>is_mdspan_property_v<P<sup>i</sup>></code> is false for any
`i`, then `mdspan` is ill-formed.
</ins>
</blockquote>
Add the following section, 23.7.� [views.mdspan.cons]:
<blockquote>
<ins style="display: block;">
**23.7.�** `mdspan` **Constructors, Assignment and Destructors [views.mdspan.cons]**
<pre>
constexpr mdspan() noexcept;
constexpr mdspan(nullptr_t) noexcept;
</pre>
*Remarks:* If `!is_dynamic_dimension(r) && extent(r) != 0` then the program is
ill-formed.
*Effects:* Constructs an empty `mdspan`.
*Postconditions:* `size() == 0 && data() == nullptr`
<pre>
template <class... DynamicExtents>
constexpr mdspan(pointer ptr, DynamicExtents... dexts);
</pre>
*Effects:* Equivalent to `mdspan(ptr, Dimensions(dexts...))`.
*Complexity:* Constant.
<pre>
constexpr mdspan(pointer ptr, layout_mapping&& l);
constexpr mdspan(pointer ptr, layout_mapping const& l);
</pre>
*Requires:*
- `l.size() >= 0`.
- If `ptr` is null, then `l.size()` shall be 0.
- If `ptr` is not null, `ptr` shall point to the beginning of a valid sequence
of objects of at least `l.size()` length.
*Effects:* Constructs an `mdspan` that is a view over the sequence of objects
pointed to be `ptr` with mapping `l`. If `ptr` is null or `l.size()` is 0, then
an empty `mdspan` is constructed.
*Complexity:* Constant.
*Throws:* Nothing.
<pre>
constexpr mdspan(mdspan const& other) noexcept = default;
constexpr mdspan(mdspan&& other) noexcept = default;
</pre>
*Effects:* Constructs an `mdspan` by copying from another `mdspan`.
*Postconditions:* `other.size() == size() && other.data() == data() && other.mapping() == mapping()`
<pre>
template <class UElementType, class UDimensions, class... UProperties>
constexpr mdspan(mdspan<UElementType, UDimensions, UProperties...> const& other);
template <class UElementType, class UDimensions, class... UProperties>
constexpr mdspan(mdspan<UElementType, UDimensions, UProperties...>&& other);
</pre>
*Remarks:* This constructor shall not participate in overload resolution unless
`mdspan<UElementType, UDimensions, UProperties...>::pointer` is implicitly
convertible to `pointer`.
*Requires:* If `!other.is_dynamic_dimension(r)` then `other.extent(r)` shall be
equal to `extent(r)`, for all `r`.
*Effects:* Constructs an `mdspan` by copying from another `mdspan`.
*Postconditions:* `other.size() == size() && reinterpret_cast<pointer>(other.data()) == data() && other.mapping() == mapping()`
*Complexity:* Constant.
*Throws:* Nothing.
<pre>
mdspan& operator=(mdspan const& other) noexcept = default;
mdspan& operator=(mdspan&& other) noexcept = default;
</pre>
*Effects:* Assigns from one `mdspan` to another.
*Postconditions:* `other.size() == size() && other.data() == data() && other.mapping() == mapping()`
<pre>
template <class UElementType, class UDimensions, class... UProperties>
mdspan& operator=(mdspan<UElementType, UDimensions, UProperties...> const& other);
template <class UElementType, class UDimensions, class... UProperties>
mdspan& operator=(mdspan<UElementType, UDimensions, UProperties...>&& other);
</pre>
*Remarks:* This operator shall not participate in overload resolution unless
`mdspan<UElementType, UDimensions, UProperties...>::pointer` is implicitly
convertible to `pointer`.
*Requires:* If `!other.is_dynamic_dimension(r)` then `other.extent(r)` shall be
equal to `extent(r)`, for all `r`.
*Effects:* Assigns from one `mdspan` to another.
*Postconditions:* `other.size() == size() && other.data() == data() && other.mapping() == mapping()`
</ins>
</blockquote>
<!--
Add the following section, 23.7.� [views.mdspan.sub]:
<blockquote>
<ins style="display: block;">
**23.7.�** `mdspan` **Subviews [views.mdspan.sub]**
<pre>
template <class... SliceSpecifiers>
<i>see-below</i> subarray(SliceSpecifiers&&... ss);
</pre>
TODO
</ins>
</blockquote>
-->
Add the following section, 23.7.� [views.mdspan.domobs]:
<blockquote>
<ins style="display: block;">
**23.7.�** `mdspan` **Domain Observers [views.mdspan.domobs]**
<pre>
static constexpr index_type rank() noexcept;
</pre>
*Effects:* Equivalent to `return layout_mapping::rank();`
<pre>
static constexpr index_type rank_dynamic() noexcept;
</pre>
*Effects:* Equivalent to `return layout_mapping::rank_dynamic();`
<pre>
constexpr bool is_dynamic_dimension(rank_type r) const noexcept;
</pre>
*Effects:* Equivalent to `return mapping().is_dynamic_dimension(r);`
<pre>
constexpr index_type extent(rank_type r) const noexcept;
</pre>
*Effects:* Equivalent to `return mapping()[r];`
<pre>
constexpr index_type size() const noexcept;
constexpr index_type length() const noexcept;
</pre>
*Effects:* Equivalent to `return mapping().size();`
<pre>
constexpr bool empty() const noexcept;
</pre>
*Effects:* Equivalent to `return size() == 0;`
</ins>
</blockquote>
Add the following section, 23.7.� [views.mdspan.codobs]:
<blockquote>
<ins style="display: block;">
**23.7.�** `mdspan` **Codomain Observers [views.mdspan.codobs]**
<pre>
constexpr index_type span() const noexcept;
</pre>
*Effects:* Equivalent to `return mapping().span();`
</ins>
</blockquote>
Add the following section, 23.7.� [views.mdspan.mapobs]:
<blockquote>
<ins style="display: block;">
**23.7.�** `mdspan` **Mapping Observers [views.mdspan.mapobs]**
<pre>
constexpr index_type stride(rank_type r) const noexcept;
</pre>
*Remarks:* This function shall not participate in overload resolution if
`layout_mapping::is_always_strided(r)` is true for all r.
*Effects:* Equivalent to `return mapping().stride(r);`
<pre>
constexpr layout_mapping mapping() const noexcept;
</pre>
*Effects:* Returns a copy of the `mdspan`'s layout mapping.
</ins>
</blockquote>
Add the following section, 23.7.� [views.mdspan.mapobs]:
<blockquote>
<ins style="display: block;">
**23.7.�** `mdspan` **Element Access [views.mdspan.elem]**
<pre>
template <class... Indices>
reference operator()(Indices... is) const;
</pre>
*Effects:* Returns a reference to the element at position `mapping()(is...)`.
*Complexity:* Constant
*Throws:* Nothing
<pre>
constexpr pointer data() const noexcept;
</pre>
*Effects:* If `!empty()`, returns a pointer to the first element in the
sequence accessible via the `mdspan`. Otherwise, returns `nullptr`.
*Complexity:* Constant
</ins>
</blockquote>
Layout Mapping Properties {#laymap}
----------------
Add the following section, 23.7.� [views.layout.props]:
<blockquote>
<ins style="display: block;">
**23.7.� Layout Mapping Properties [views.layout.props]**
In the following section, let `D` be an instantiation of the `dimensions` class
template.
`layout_right` shall be a layout ([views.layout.requirements]) such
that `layout_right::mapping<D>().stride(D::rank() - 1) == 1`.
`layout_left` shall be a layout such that
`layout_left::mapping<D>().stride(0) == 1`.
</ins>
</blockquote>
Feature Testing {#test}
===============
The `__cpp_lib_mdspan` feature test macro should be added.