From Jason Turner

[mdspan.accessor]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp7co1f0je/{from.md → to.md} +156 -0
tmp/tmp7co1f0je/{from.md → to.md} RENAMED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Accessor policy <a id="mdspan.accessor">[[mdspan.accessor]]</a>
2
+
3
+ ##### General <a id="mdspan.accessor.general">[[mdspan.accessor.general]]</a>
4
+
5
+ An *accessor policy* defines types and operations by which a reference
6
+ to a single object is created from an abstract data handle to a number
7
+ of such objects and an index.
8
+
9
+ A range of indices [0, N) is an *accessible range* of a given data
10
+ handle and an accessor if, for each i in the range, the accessor
11
+ policy’s `access` function produces a valid reference to an object.
12
+
13
+ In subclause [[mdspan.accessor.reqmts]],
14
+
15
+ - `A` denotes an accessor policy.
16
+ - `a` denotes a value of type `A` or `const A`.
17
+ - `p` denotes a value of type `A::data_handle_type` or
18
+ `const A::data_handle_type`. \[*Note 1*: The type
19
+ `A::data_handle_type` need not be dereferenceable. — *end note*]
20
+ - `n`, `i`, and `j` each denote values of type `size_t`.
21
+
22
+ ##### Requirements <a id="mdspan.accessor.reqmts">[[mdspan.accessor.reqmts]]</a>
23
+
24
+ A type `A` meets the accessor policy requirements if
25
+
26
+ - `A` models `copyable`,
27
+ - `is_nothrow_move_constructible_v<A>` is `true`,
28
+ - `is_nothrow_move_assignable_v<A>` is `true`,
29
+ - `is_nothrow_swappable_v<A>` is `true`, and
30
+ - the following types and expressions are well-formed and have the
31
+ specified semantics.
32
+
33
+ ``` cpp
34
+ typename A::element_type
35
+ ```
36
+
37
+ *Result:* A complete object type that is not an abstract class type.
38
+
39
+ ``` cpp
40
+ typename A::data_handle_type
41
+ ```
42
+
43
+ *Result:* A type that models `copyable`, and for which
44
+ `is_nothrow_move_constructible_v<A::data_handle_type>` is `true`,
45
+ `is_nothrow_move_assignable_v<A::data_handle_type>` is `true`, and
46
+ `is_nothrow_swappable_v<A::data_handle_type>` is `true`.
47
+
48
+ [*Note 1*: The type of `data_handle_type` need not be
49
+ `element_type*`. — *end note*]
50
+
51
+ ``` cpp
52
+ typename A::reference
53
+ ```
54
+
55
+ *Result:* A type that models
56
+ `common_reference_with<A::reference&&, A::element_type&>`.
57
+
58
+ [*Note 2*: The type of `reference` need not be
59
+ `element_type&`. — *end note*]
60
+
61
+ ``` cpp
62
+ typename A::offset_policy
63
+ ```
64
+
65
+ *Result:* A type `OP` such that:
66
+
67
+ - `OP` meets the accessor policy requirements,
68
+ - `constructible_from<OP, const A&>` is modeled, and
69
+ - `is_same_v<typename OP::element_type, typename A::element_type>` is
70
+ `true`.
71
+
72
+ ``` cpp
73
+ a.access(p, i)
74
+ ```
75
+
76
+ *Result:* `A::reference`
77
+
78
+ *Remarks:* The expression is equality preserving.
79
+
80
+ [*Note 3*: Concrete accessor policies can impose preconditions for
81
+ their `access` function. However, they might not. For example, an
82
+ accessor where `p` is `span<A::element_type, dynamic_extent>` and
83
+ `access(p, i)` returns `p[i % p.size()]` does not need to impose a
84
+ precondition on `i`. — *end note*]
85
+
86
+ ``` cpp
87
+ a.offset(p, i)
88
+ ```
89
+
90
+ *Result:* `A::offset_policy::data_handle_type`
91
+
92
+ *Returns:* `q` such that for `b` being `A::offset_policy(a)`, and any
93
+ integer `n` for which [0, `n`) is an accessible range of `p` and `a`:
94
+
95
+ - [0, `n` - `i`) is an accessible range of `q` and `b`; and
96
+ - `b.access(q, j)` provides access to the same element as
97
+ `a.access(p, i + j)`, for every `j` in the range [0, `n` - `i`).
98
+
99
+ *Remarks:* The expression is equality-preserving.
100
+
101
+ ##### Class template `default_accessor` <a id="mdspan.accessor.default">[[mdspan.accessor.default]]</a>
102
+
103
+ ###### Overview <a id="mdspan.accessor.default.overview">[[mdspan.accessor.default.overview]]</a>
104
+
105
+ ``` cpp
106
+ namespace std {
107
+ template<class ElementType>
108
+ struct default_accessor {
109
+ using offset_policy = default_accessor;
110
+ using element_type = ElementType;
111
+ using reference = ElementType&;
112
+ using data_handle_type = ElementType*;
113
+
114
+ constexpr default_accessor() noexcept = default;
115
+ template<class OtherElementType>
116
+ constexpr default_accessor(default_accessor<OtherElementType>) noexcept;
117
+ constexpr reference access(data_handle_type p, size_t i) const noexcept;
118
+ constexpr data_handle_type offset(data_handle_type p, size_t i) const noexcept;
119
+ };
120
+ }
121
+ ```
122
+
123
+ `default_accessor` meets the accessor policy requirements.
124
+
125
+ `ElementType` is required to be a complete object type that is neither
126
+ an abstract class type nor an array type.
127
+
128
+ Each specialization of `default_accessor` is a trivially copyable type
129
+ that models `semiregular`.
130
+
131
+ [0, n) is an accessible range for an object `p` of type
132
+ `data_handle_type` and an object of type `default_accessor` if and only
133
+ if \[`p`, `p + `n) is a valid range.
134
+
135
+ ###### Members <a id="mdspan.accessor.default.members">[[mdspan.accessor.default.members]]</a>
136
+
137
+ ``` cpp
138
+ template<class OtherElementType>
139
+ constexpr default_accessor(default_accessor<OtherElementType>) noexcept {}
140
+ ```
141
+
142
+ *Constraints:*
143
+ `is_convertible_v<OtherElementType(*)[], element_type(*)[]>` is `true`.
144
+
145
+ ``` cpp
146
+ constexpr reference access(data_handle_type p, size_t i) const noexcept;
147
+ ```
148
+
149
+ *Effects:* Equivalent to: `return p[i];`
150
+
151
+ ``` cpp
152
+ constexpr data_handle_type offset(data_handle_type p, size_t i) const noexcept;
153
+ ```
154
+
155
+ *Effects:* Equivalent to: `return p + i;`
156
+