From Jason Turner

[mdspan.mdspan.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpb8o7a4y4/{from.md → to.md} +156 -0
tmp/tmpb8o7a4y4/{from.md → to.md} RENAMED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##### Overview <a id="mdspan.mdspan.overview">[[mdspan.mdspan.overview]]</a>
2
+
3
+ `mdspan` is a view of a multidimensional array of elements.
4
+
5
+ ``` cpp
6
+ namespace std {
7
+ template<class ElementType, class Extents, class LayoutPolicy = layout_right,
8
+ class AccessorPolicy = default_accessor<ElementType>>
9
+ class mdspan {
10
+ public:
11
+ using extents_type = Extents;
12
+ using layout_type = LayoutPolicy;
13
+ using accessor_type = AccessorPolicy;
14
+ using mapping_type = typename layout_type::template mapping<extents_type>;
15
+ using element_type = ElementType;
16
+ using value_type = remove_cv_t<element_type>;
17
+ using index_type = typename extents_type::index_type;
18
+ using size_type = typename extents_type::size_type;
19
+ using rank_type = typename extents_type::rank_type;
20
+ using data_handle_type = typename accessor_type::data_handle_type;
21
+ using reference = typename accessor_type::reference;
22
+
23
+ static constexpr rank_type rank() noexcept { return extents_type::rank(); }
24
+ static constexpr rank_type rank_dynamic() noexcept { return extents_type::rank_dynamic(); }
25
+ static constexpr size_t static_extent(rank_type r) noexcept
26
+ { return extents_type::static_extent(r); }
27
+ constexpr index_type extent(rank_type r) const noexcept { return extents().extent(r); }
28
+
29
+ // [mdspan.mdspan.cons], constructors
30
+ constexpr mdspan();
31
+ constexpr mdspan(const mdspan& rhs) = default;
32
+ constexpr mdspan(mdspan&& rhs) = default;
33
+
34
+ template<class... OtherIndexTypes>
35
+ constexpr explicit mdspan(data_handle_type ptr, OtherIndexTypes... exts);
36
+ template<class OtherIndexType, size_t N>
37
+ constexpr explicit(N != rank_dynamic())
38
+ mdspan(data_handle_type p, span<OtherIndexType, N> exts);
39
+ template<class OtherIndexType, size_t N>
40
+ constexpr explicit(N != rank_dynamic())
41
+ mdspan(data_handle_type p, const array<OtherIndexType, N>& exts);
42
+ constexpr mdspan(data_handle_type p, const extents_type& ext);
43
+ constexpr mdspan(data_handle_type p, const mapping_type& m);
44
+ constexpr mdspan(data_handle_type p, const mapping_type& m, const accessor_type& a);
45
+
46
+ template<class OtherElementType, class OtherExtents,
47
+ class OtherLayoutPolicy, class OtherAccessorPolicy>
48
+ constexpr explicit(see below)
49
+ mdspan(const mdspan<OtherElementType, OtherExtents,
50
+ OtherLayoutPolicy, OtherAccessorPolicy>& other);
51
+
52
+ constexpr mdspan& operator=(const mdspan& rhs) = default;
53
+ constexpr mdspan& operator=(mdspan&& rhs) = default;
54
+
55
+ // [mdspan.mdspan.members], members
56
+ template<class... OtherIndexTypes>
57
+ constexpr reference operator[](OtherIndexTypes... indices) const;
58
+ template<class OtherIndexType>
59
+ constexpr reference operator[](span<OtherIndexType, rank()> indices) const;
60
+ template<class OtherIndexType>
61
+ constexpr reference operator[](const array<OtherIndexType, rank()>& indices) const;
62
+
63
+ constexpr size_type size() const noexcept;
64
+ [[nodiscard]] constexpr bool empty() const noexcept;
65
+
66
+ friend constexpr void swap(mdspan& x, mdspan& y) noexcept;
67
+
68
+ constexpr const extents_type& extents() const noexcept { return map_.extents(); }
69
+ constexpr const data_handle_type& data_handle() const noexcept { return ptr_; }
70
+ constexpr const mapping_type& mapping() const noexcept { return map_; }
71
+ constexpr const accessor_type& accessor() const noexcept { return acc_; }
72
+
73
+ static constexpr bool is_always_unique()
74
+ { return mapping_type::is_always_unique(); }
75
+ static constexpr bool is_always_exhaustive()
76
+ { return mapping_type::is_always_exhaustive(); }
77
+ static constexpr bool is_always_strided()
78
+ { return mapping_type::is_always_strided(); }
79
+
80
+ constexpr bool is_unique() const
81
+ { return map_.is_unique(); }
82
+ constexpr bool is_exhaustive() const
83
+ { return map_.is_exhaustive(); }
84
+ constexpr bool is_strided() const
85
+ { return map_.is_strided(); }
86
+ constexpr index_type stride(rank_type r) const
87
+ { return map_.stride(r); }
88
+
89
+ private:
90
+ accessor_type acc_; // exposition only
91
+ mapping_type map_; // exposition only
92
+ data_handle_type ptr_; // exposition only
93
+ };
94
+
95
+ template<class CArray>
96
+ requires(is_array_v<CArray> && rank_v<CArray> == 1)
97
+ mdspan(CArray&)
98
+ -> mdspan<remove_all_extents_t<CArray>, extents<size_t, extent_v<CArray, 0>>>;
99
+
100
+ template<class Pointer>
101
+ requires(is_pointer_v<remove_reference_t<Pointer>>)
102
+ mdspan(Pointer&&)
103
+ -> mdspan<remove_pointer_t<remove_reference_t<Pointer>>, extents<size_t>>;
104
+
105
+ template<class ElementType, class... Integrals>
106
+ requires((is_convertible_v<Integrals, size_t> && ...) && sizeof...(Integrals) > 0)
107
+ explicit mdspan(ElementType*, Integrals...)
108
+ -> mdspan<ElementType, dextents<size_t, sizeof...(Integrals)>>;
109
+
110
+ template<class ElementType, class OtherIndexType, size_t N>
111
+ mdspan(ElementType*, span<OtherIndexType, N>)
112
+ -> mdspan<ElementType, dextents<size_t, N>>;
113
+
114
+ template<class ElementType, class OtherIndexType, size_t N>
115
+ mdspan(ElementType*, const array<OtherIndexType, N>&)
116
+ -> mdspan<ElementType, dextents<size_t, N>>;
117
+
118
+ template<class ElementType, class IndexType, size_t... ExtentsPack>
119
+ mdspan(ElementType*, const extents<IndexType, ExtentsPack...>&)
120
+ -> mdspan<ElementType, extents<IndexType, ExtentsPack...>>;
121
+
122
+ template<class ElementType, class MappingType>
123
+ mdspan(ElementType*, const MappingType&)
124
+ -> mdspan<ElementType, typename MappingType::extents_type,
125
+ typename MappingType::layout_type>;
126
+
127
+ template<class MappingType, class AccessorType>
128
+ mdspan(const typename AccessorType::data_handle_type&, const MappingType&,
129
+ const AccessorType&)
130
+ -> mdspan<typename AccessorType::element_type, typename MappingType::extents_type,
131
+ typename MappingType::layout_type, AccessorType>;
132
+ }
133
+ ```
134
+
135
+ *Mandates:*
136
+
137
+ - `ElementType` is a complete object type that is neither an abstract
138
+ class type nor an array type,
139
+ - `Extents` is a specialization of `extents`, and
140
+ - `is_same_v<ElementType, typename AccessorPolicy::element_type>` is
141
+ `true`.
142
+
143
+ `LayoutPolicy` shall meet the layout mapping policy requirements
144
+ [[mdspan.layout.policy.reqmts]], and `AccessorPolicy` shall meet the
145
+ accessor policy requirements [[mdspan.accessor.reqmts]].
146
+
147
+ Each specialization `MDS` of `mdspan` models `copyable` and
148
+
149
+ - `is_nothrow_move_constructible_v<MDS>` is `true`,
150
+ - `is_nothrow_move_assignable_v<MDS>` is `true`, and
151
+ - `is_nothrow_swappable_v<MDS>` is `true`.
152
+
153
+ A specialization of `mdspan` is a trivially copyable type if its
154
+ `accessor_type`, `mapping_type`, and `data_handle_type` are trivially
155
+ copyable types.
156
+