26
26
namespace mbed {
27
27
28
28
/* *
29
- * Special value for the Size parameter of Span.
29
+ * Special value for the Extent parameter of Span.
30
30
* If the type use this value then the size of the array is stored in the object
31
31
* at runtime.
32
32
*/
@@ -47,18 +47,18 @@ namespace mbed {
47
47
* @note You can create Span instances with the help of the function
48
48
* template make_Span() and make_const_Span().
49
49
*
50
- * @note Span<T, Size > objects can be implicitly converted to Span<T> objects
50
+ * @note Span<T, Extent > objects can be implicitly converted to Span<T> objects
51
51
* where required.
52
52
*
53
53
* @tparam T type of objects held by the array.
54
- * @tparam Size The size of the array viewed. The default value
54
+ * @tparam Extent The size of the array viewed. The default value
55
55
* SPAN_DYNAMIC_SIZE is special as it allows construction of Span objects of
56
56
* any size (set at runtime).
57
57
*/
58
- template <typename T, ptrdiff_t Size = SPAN_DYNAMIC_EXTENT>
58
+ template <typename T, ptrdiff_t Extent = SPAN_DYNAMIC_EXTENT>
59
59
struct Span {
60
60
61
- MBED_STATIC_ASSERT (Size >= 0 , " Invalid size for a Span" );
61
+ MBED_STATIC_ASSERT (Extent >= 0 , " Invalid extent for a Span" );
62
62
63
63
/* *
64
64
* Construct a view to an empty array.
@@ -78,20 +78,18 @@ struct Span {
78
78
*/
79
79
Span (T *array_ptr, size_t array_size) :
80
80
_array (array_ptr) {
81
- MBED_ASSERT (array_size >= (size_t ) Size );
81
+ MBED_ASSERT (array_size >= (size_t ) Extent );
82
82
}
83
83
84
84
/* *
85
85
* Construct a Span from the reference to an array.
86
86
*
87
87
* @param elements Reference to the array viewed.
88
88
*
89
- * @tparam Size Number of elements of T presents in the array.
90
- *
91
- * @post a call to size() will return Size, and data() will return
89
+ * @post a call to size() will return Extent, and data() will return
92
90
* a pointer to elements.
93
91
*/
94
- Span (T (&elements)[Size ]):
92
+ Span (T (&elements)[Extent ]):
95
93
_array (elements) { }
96
94
97
95
/* *
@@ -101,7 +99,7 @@ struct Span {
101
99
*/
102
100
size_t size () const
103
101
{
104
- return _array ? Size : 0 ;
102
+ return _array ? Extent : 0 ;
105
103
}
106
104
107
105
/* *
@@ -170,7 +168,7 @@ struct Span {
170
168
* @return A new Span over the first @p count elements.
171
169
*/
172
170
Span<T> first (std::size_t count) const {
173
- MBED_ASSERT (count <= Size );
171
+ MBED_ASSERT (count <= Extent );
174
172
return Span<T>(_array, count);
175
173
}
176
174
@@ -183,7 +181,7 @@ struct Span {
183
181
*/
184
182
template <std::ptrdiff_t Count>
185
183
Span<T, Count> first () const {
186
- MBED_ASSERT (Count <= Size );
184
+ MBED_ASSERT (Count <= Extent );
187
185
return Span<T, Count>(_array);
188
186
}
189
187
@@ -195,8 +193,8 @@ struct Span {
195
193
* @return A new Span over the last @p count elements.
196
194
*/
197
195
Span<T> last (std::size_t count) const {
198
- MBED_ASSERT (count <= Size );
199
- return Span<T>(_array + (Size - count), count);
196
+ MBED_ASSERT (count <= Extent );
197
+ return Span<T>(_array + (Extent - count), count);
200
198
}
201
199
202
200
/* *
@@ -208,8 +206,8 @@ struct Span {
208
206
*/
209
207
template <std::ptrdiff_t Count>
210
208
Span<T, Count> last () const {
211
- MBED_ASSERT (Count <= Size );
212
- return Span<T, Count>(_array + (Size - Count));
209
+ MBED_ASSERT (Count <= Extent );
210
+ return Span<T, Count>(_array + (Extent - Count));
213
211
}
214
212
215
213
private:
@@ -261,8 +259,8 @@ struct Span<T, SPAN_DYNAMIC_EXTENT> {
261
259
* static size.
262
260
* @param other The Span object used to construct this.
263
261
*/
264
- template <size_t Size >
265
- Span (const Span<T, Size > &other):
262
+ template <size_t Extent >
263
+ Span (const Span<T, Extent > &other):
266
264
_array (other.data()), _size(other.size()) { }
267
265
268
266
/* *
@@ -370,8 +368,8 @@ struct Span<T, SPAN_DYNAMIC_EXTENT> {
370
368
* @return True if arrays in input have the same size and the same content
371
369
* and false otherwise.
372
370
*/
373
- template <typename T, typename U, ptrdiff_t LhsSize , ptrdiff_t RhsSize >
374
- bool operator ==(const Span<T, LhsSize > &lhs, const Span<U, RhsSize > &rhs)
371
+ template <typename T, typename U, ptrdiff_t LhsExtent , ptrdiff_t RhsExtent >
372
+ bool operator ==(const Span<T, LhsExtent > &lhs, const Span<U, RhsExtent > &rhs)
375
373
{
376
374
if (lhs.size () != rhs.size ()) {
377
375
return false ;
@@ -393,8 +391,8 @@ bool operator==(const Span<T, LhsSize> &lhs, const Span<U, RhsSize> &rhs)
393
391
* @return True if arrays in input have the same size and the same content
394
392
* and false otherwise.
395
393
*/
396
- template <typename T, ptrdiff_t LhsSize , ptrdiff_t RhsSize >
397
- bool operator ==(const Span<T, LhsSize > &lhs, T (&rhs)[RhsSize ])
394
+ template <typename T, ptrdiff_t LhsExtent , ptrdiff_t RhsExtent >
395
+ bool operator ==(const Span<T, LhsExtent > &lhs, T (&rhs)[RhsExtent ])
398
396
{
399
397
return lhs == Span<T>(rhs);
400
398
}
@@ -408,8 +406,8 @@ bool operator==(const Span<T, LhsSize> &lhs, T (&rhs)[RhsSize])
408
406
* @return True if arrays in input have the same size and the same content
409
407
* and false otherwise.
410
408
*/
411
- template <typename T, ptrdiff_t LhsSize , ptrdiff_t RhsSize >
412
- bool operator ==(T (&lhs)[LhsSize ], const Span<T, RhsSize > &rhs)
409
+ template <typename T, ptrdiff_t LhsExtent , ptrdiff_t RhsExtent >
410
+ bool operator ==(T (&lhs)[LhsExtent ], const Span<T, RhsExtent > &rhs)
413
411
{
414
412
return Span<T>(lhs) == rhs;
415
413
}
@@ -423,8 +421,8 @@ bool operator==(T (&lhs)[LhsSize], const Span<T, RhsSize> &rhs)
423
421
* @return True if arrays in input do not have the same size or the same
424
422
* content and false otherwise.
425
423
*/
426
- template <typename T, typename U, ptrdiff_t LhsSize , ptrdiff_t RhsSize >
427
- bool operator !=(const Span<T, LhsSize > &lhs, const Span<U, RhsSize > &rhs)
424
+ template <typename T, typename U, ptrdiff_t LhsExtent , ptrdiff_t RhsExtent >
425
+ bool operator !=(const Span<T, LhsExtent > &lhs, const Span<U, RhsExtent > &rhs)
428
426
{
429
427
return !(lhs == rhs);
430
428
}
@@ -438,10 +436,10 @@ bool operator!=(const Span<T, LhsSize> &lhs, const Span<U, RhsSize> &rhs)
438
436
* @return True if arrays in input have the same size and the same content
439
437
* and false otherwise.
440
438
*/
441
- template <typename T, ptrdiff_t LhsSize , ptrdiff_t RhsSize >
442
- bool operator !=(const Span<T, LhsSize > &lhs, T (&rhs)[RhsSize ])
439
+ template <typename T, ptrdiff_t LhsExtent , ptrdiff_t RhsExtent >
440
+ bool operator !=(const Span<T, LhsExtent > &lhs, T (&rhs)[RhsExtent ])
443
441
{
444
- return !(lhs == Span<T, RhsSize >(rhs));
442
+ return !(lhs == Span<T, RhsExtent >(rhs));
445
443
}
446
444
447
445
/* *
@@ -453,17 +451,17 @@ bool operator!=(const Span<T, LhsSize> &lhs, T (&rhs)[RhsSize])
453
451
* @return True if arrays in input have the same size and the same content
454
452
* and false otherwise.
455
453
*/
456
- template <typename T, ptrdiff_t LhsSize , ptrdiff_t RhsSize >
457
- bool operator !=(T (&lhs)[LhsSize ], const Span<T, RhsSize > &rhs)
454
+ template <typename T, ptrdiff_t LhsExtent , ptrdiff_t RhsExtent >
455
+ bool operator !=(T (&lhs)[LhsExtent ], const Span<T, RhsExtent > &rhs)
458
456
{
459
- return !(Span<T, LhsSize >(lhs) == rhs);
457
+ return !(Span<T, LhsExtent >(lhs) == rhs);
460
458
}
461
459
462
460
/* *
463
461
* Generate a Span from a reference to a C/C++ array.
464
462
*
465
463
* @tparam T Type of elements held in elements.
466
- * @tparam Size Number of items held in elements.
464
+ * @tparam Extent Number of items held in elements.
467
465
*
468
466
* @param elements The reference to the array viewed.
469
467
*
@@ -472,16 +470,16 @@ bool operator!=(T (&lhs)[LhsSize], const Span<T, RhsSize> &rhs)
472
470
* @note This helper avoids the typing of template parameter when Span is
473
471
* created 'inline'.
474
472
*/
475
- template <typename T, size_t Size >
476
- Span<T, Size > make_Span (T (&elements)[Size ])
473
+ template <typename T, size_t Extent >
474
+ Span<T, Extent > make_Span (T (&elements)[Extent ])
477
475
{
478
- return Span<T, Size >(elements);
476
+ return Span<T, Extent >(elements);
479
477
}
480
478
481
479
/* *
482
480
* Generate a Span from a pointer to a C/C++ array.
483
481
*
484
- * @tparam Size Number of items held in elements.
482
+ * @tparam Extent Number of items held in elements.
485
483
* @tparam T Type of elements held in elements.
486
484
*
487
485
* @param elements The reference to the array viewed.
@@ -491,10 +489,10 @@ Span<T, Size> make_Span(T (&elements)[Size])
491
489
* @note This helper avoids the typing of template parameter when Span is
492
490
* created 'inline'.
493
491
*/
494
- template <size_t Size , typename T>
495
- Span<T, Size > make_Span (T *elements)
492
+ template <size_t Extent , typename T>
493
+ Span<T, Extent > make_Span (T *elements)
496
494
{
497
- return Span<T, Size >(elements, Size );
495
+ return Span<T, Extent >(elements, Extent );
498
496
}
499
497
500
498
/* *
@@ -520,24 +518,24 @@ Span<T> make_Span(T *array_ptr, size_t array_size)
520
518
* Generate a Span to a const content from a reference to a C/C++ array.
521
519
*
522
520
* @tparam T Type of elements held in elements.
523
- * @tparam Size Number of items held in elements.
521
+ * @tparam Extent Number of items held in elements.
524
522
*
525
523
* @param elements The array viewed.
526
524
* @return The Span to elements.
527
525
*
528
526
* @note This helper avoids the typing of template parameter when Span is
529
527
* created 'inline'.
530
528
*/
531
- template <typename T, size_t Size >
532
- Span<const T, Size > make_const_Span (const T (&elements)[Size ])
529
+ template <typename T, size_t Extent >
530
+ Span<const T, Extent > make_const_Span (const T (&elements)[Extent ])
533
531
{
534
- return Span<const T, Size >(elements);
532
+ return Span<const T, Extent >(elements);
535
533
}
536
534
537
535
/* *
538
536
* Generate a Span to a const content from a pointer to a C/C++ array.
539
537
*
540
- * @tparam Size Number of items held in elements.
538
+ * @tparam Extent Number of items held in elements.
541
539
* @tparam T Type of elements held in elements.
542
540
*
543
541
* @param elements The reference to the array viewed.
@@ -547,10 +545,10 @@ Span<const T, Size> make_const_Span(const T (&elements)[Size])
547
545
* @note This helper avoids the typing of template parameter when Span is
548
546
* created 'inline'.
549
547
*/
550
- template <size_t Size , typename T>
551
- Span<const T, Size > make_const_Span (const T *elements)
548
+ template <size_t Extent , typename T>
549
+ Span<const T, Extent > make_const_Span (const T *elements)
552
550
{
553
- return Span<const T, Size >(elements, Size );
551
+ return Span<const T, Extent >(elements, Extent );
554
552
}
555
553
556
554
/* *
0 commit comments