25
25
26
26
namespace mbed {
27
27
28
+ /* * \addtogroup platform */
29
+ /* * @{*/
30
+ /* *
31
+ * \defgroup platform_Span Span class
32
+ * @{
33
+ */
34
+
28
35
// Internal details of Span
29
36
// It is used construct Span from Span of convertible types (non const -> const)
30
37
namespace span_detail {
@@ -47,12 +54,18 @@ class is_convertible
47
54
48
55
}
49
56
57
+ #if defined(DOXYGEN_ONLY)
50
58
/* *
51
59
* Special value for the Extent parameter of Span.
52
60
* If the type uses this value, then the size of the array is stored in the object
53
61
* at runtime.
62
+ *
63
+ * @relates Span
54
64
*/
65
+ const ptrdiff_t SPAN_DYNAMIC_EXTENT = -1 ;
66
+ #else
55
67
#define SPAN_DYNAMIC_EXTENT -1
68
+ #endif
56
69
57
70
/* *
58
71
* Nonowning view to a sequence of contiguous elements.
@@ -691,15 +704,15 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
691
704
* @return A subspan of this starting at Offset and Count long.
692
705
*/
693
706
template <std::ptrdiff_t Offset, std::ptrdiff_t Count>
694
- Span<element_type, Count == SPAN_DYNAMIC_EXTENT ? SPAN_DYNAMIC_EXTENT : Count >
707
+ Span<element_type, Count>
695
708
subspan () const
696
709
{
697
710
MBED_ASSERT (0 <= Offset && Offset <= _size);
698
711
MBED_ASSERT (
699
712
(Count == SPAN_DYNAMIC_EXTENT) ||
700
713
(0 <= Count && (Count + Offset) <= _size)
701
714
);
702
- return Span<element_type, Count == SPAN_DYNAMIC_EXTENT ? SPAN_DYNAMIC_EXTENT : Count >(
715
+ return Span<element_type, Count>(
703
716
_data + Offset,
704
717
Count == SPAN_DYNAMIC_EXTENT ? _size - Offset : Count
705
718
);
@@ -774,6 +787,8 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
774
787
*
775
788
* @return True if Spans in input have the same size and the same content and
776
789
* false otherwise.
790
+ *
791
+ * @relates Span
777
792
*/
778
793
template <typename T, typename U, ptrdiff_t LhsExtent, ptrdiff_t RhsExtent>
779
794
bool operator ==(const Span<T, LhsExtent> &lhs, const Span<U, RhsExtent> &rhs)
@@ -827,6 +842,8 @@ bool operator==(T (&lhs)[LhsExtent], const Span<T, RhsExtent> &rhs)
827
842
*
828
843
* @return True if arrays in input do not have the same size or the same content
829
844
* and false otherwise.
845
+ *
846
+ * @relates Span
830
847
*/
831
848
template <typename T, typename U, ptrdiff_t LhsExtent, ptrdiff_t RhsExtent>
832
849
bool operator !=(const Span<T, LhsExtent> &lhs, const Span<U, RhsExtent> &rhs)
@@ -876,6 +893,8 @@ bool operator!=(T (&lhs)[LhsExtent], const Span<T, RhsExtent> &rhs)
876
893
*
877
894
* @note This helper avoids the typing of template parameter when Span is
878
895
* created 'inline'.
896
+ *
897
+ * @relates Span
879
898
*/
880
899
template <typename T, size_t Size>
881
900
Span<T, Size> make_Span (T (&elements)[Size])
@@ -914,6 +933,8 @@ Span<T, Extent> make_Span(T *elements)
914
933
*
915
934
* @note This helper avoids the typing of template parameter when Span is
916
935
* created 'inline'.
936
+ *
937
+ * @relates Span
917
938
*/
918
939
template <typename T>
919
940
Span<T> make_Span (T *array_ptr, ptrdiff_t array_size)
@@ -951,6 +972,8 @@ Span<const T, Extent> make_const_Span(const T (&elements)[Extent])
951
972
*
952
973
* @note This helper avoids the typing of template parameter when Span is
953
974
* created 'inline'.
975
+ *
976
+ * @relates Span
954
977
*/
955
978
template <size_t Extent, typename T>
956
979
Span<const T, Extent> make_const_Span (const T *elements)
@@ -971,13 +994,19 @@ Span<const T, Extent> make_const_Span(const T *elements)
971
994
*
972
995
* @note This helper avoids the typing of template parameter when Span is
973
996
* created 'inline'.
997
+ *
998
+ * @relates Span
974
999
*/
975
1000
template <typename T>
976
1001
Span<const T> make_const_Span (T *array_ptr, size_t array_size)
977
1002
{
978
1003
return Span<const T>(array_ptr, array_size);
979
1004
}
980
1005
1006
+ /* *@}*/
1007
+
1008
+ /* *@}*/
1009
+
981
1010
} // namespace mbed
982
1011
983
1012
#endif /* MBED_PLATFORM_SPAN_H_ */
0 commit comments