@@ -108,25 +108,6 @@ class MRDOX_DECL
108
108
*/
109
109
Array (Array const & other);
110
110
111
- /* * Assignment.
112
-
113
- Ownership of the array is transferred
114
- to this, and ownership of the previous
115
- contents is released. The moved-from
116
- array behaves as if default constructed.
117
- */
118
- Array& operator =(Array&&);
119
-
120
- /* * Assignment.
121
-
122
- This acquires shared ownership of the copied
123
- array, and ownership of the previous contents
124
- is released.
125
- */
126
- Array& operator =(Array const &) = default ;
127
-
128
- // --------------------------------------------
129
-
130
111
/* * Constructor.
131
112
132
113
This constructs an array from an existing
@@ -150,6 +131,25 @@ class MRDOX_DECL
150
131
*/
151
132
Array (storage_type elements);
152
133
134
+ /* * Assignment.
135
+
136
+ Ownership of the array is transferred
137
+ to this, and ownership of the previous
138
+ contents is released. The moved-from
139
+ array behaves as if default constructed.
140
+ */
141
+ Array& operator =(Array&&);
142
+
143
+ /* * Assignment.
144
+
145
+ This acquires shared ownership of the copied
146
+ array, and ownership of the previous contents
147
+ is released.
148
+ */
149
+ Array& operator =(Array const &) = default ;
150
+
151
+ // --------------------------------------------
152
+
153
153
/* * Return the implementation used by this object.
154
154
*/
155
155
auto impl () const noexcept -> impl_type const &
@@ -175,6 +175,13 @@ class MRDOX_DECL
175
175
*/
176
176
value_type get (size_type i) const ;
177
177
178
+ /* * Set the i-th element, without bounds checking.
179
+
180
+ @param i The zero-based index of the element.
181
+ @param v The value to set.
182
+ */
183
+ void set (size_type i, Value v);
184
+
178
185
/* * Return the i-th element, without bounds checking.
179
186
*/
180
187
value_type operator [](size_type i) const ;
@@ -185,6 +192,18 @@ class MRDOX_DECL
185
192
*/
186
193
value_type at (size_type i) const ;
187
194
195
+ /* * Return the first element.
196
+
197
+ @throw Exception `empty()`
198
+ */
199
+ value_type front () const ;
200
+
201
+ /* * Return the last element.
202
+
203
+ @throw Exception `empty()`
204
+ */
205
+ value_type back () const ;
206
+
188
207
/* * Return an iterator to the beginning of the range of elements.
189
208
*/
190
209
iterator begin () const ;
@@ -200,6 +219,27 @@ class MRDOX_DECL
200
219
*/
201
220
void emplace_back (value_type value);
202
221
222
+ /* * Concatenate two arrays.
223
+ */
224
+ friend Array operator +(Array const & lhs, Array const & rhs);
225
+
226
+ // / @overload
227
+ template <std::convertible_to<Array> S>
228
+ friend auto operator +(
229
+ S const & lhs, Array const & rhs) noexcept
230
+ {
231
+ return Array (lhs) + rhs;
232
+ }
233
+
234
+ // / @overload
235
+ template <std::convertible_to<Array> S>
236
+ friend auto operator +(
237
+ Array const & lhs, S const & rhs) noexcept
238
+ {
239
+ return lhs + Array (rhs);
240
+ }
241
+
242
+
203
243
/* * Swap two arrays.
204
244
*/
205
245
void swap (Array& other) noexcept
@@ -214,6 +254,18 @@ class MRDOX_DECL
214
254
lhs.swap (rhs);
215
255
}
216
256
257
+ /* * Compare two arrays for equality.
258
+ */
259
+ friend
260
+ bool
261
+ operator ==(Array const &, Array const &) noexcept ;
262
+
263
+ /* * Compare two arrays for precedence.
264
+ */
265
+ friend
266
+ std::strong_ordering
267
+ operator <=>(Array const &, Array const &) noexcept ;
268
+
217
269
/* * Return a diagnostic string.
218
270
*/
219
271
friend
@@ -261,6 +313,10 @@ class MRDOX_DECL
261
313
*/
262
314
virtual value_type get (size_type i) const = 0;
263
315
316
+ /* * Set the i-th element, without bounds checking.
317
+ */
318
+ virtual void set (size_type, Value);
319
+
264
320
/* * Append an element to the end of the array.
265
321
266
322
The default implementation throws an exception,
@@ -298,6 +354,7 @@ class MRDOX_DECL
298
354
storage_type elements) noexcept ;
299
355
size_type size () const override ;
300
356
value_type get (size_type i) const override ;
357
+ void set (size_type i, Value v) override ;
301
358
void emplace_back (value_type value) override ;
302
359
303
360
private:
0 commit comments