Skip to content

Commit 408051a

Browse files
Cruz Monrreal IICruz Monrreal II
authored andcommitted
Merge branch 'span-doc' of ssh://github.com/pan-/mbed into rollup
2 parents 0e2983e + 1e30ed5 commit 408051a

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

platform/Span.h

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525

2626
namespace mbed {
2727

28+
/** \addtogroup platform */
29+
/** @{*/
30+
/**
31+
* \defgroup platform_Span Span class
32+
* @{
33+
*/
34+
2835
// Internal details of Span
2936
// It is used construct Span from Span of convertible types (non const -> const)
3037
namespace span_detail {
@@ -47,12 +54,18 @@ class is_convertible
4754

4855
}
4956

57+
#if defined(DOXYGEN_ONLY)
5058
/**
5159
* Special value for the Extent parameter of Span.
5260
* If the type uses this value, then the size of the array is stored in the object
5361
* at runtime.
62+
*
63+
* @relates Span
5464
*/
65+
const ptrdiff_t SPAN_DYNAMIC_EXTENT = -1;
66+
#else
5567
#define SPAN_DYNAMIC_EXTENT -1
68+
#endif
5669

5770
/**
5871
* Nonowning view to a sequence of contiguous elements.
@@ -691,15 +704,15 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
691704
* @return A subspan of this starting at Offset and Count long.
692705
*/
693706
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>
695708
subspan() const
696709
{
697710
MBED_ASSERT(0 <= Offset && Offset <= _size);
698711
MBED_ASSERT(
699712
(Count == SPAN_DYNAMIC_EXTENT) ||
700713
(0 <= Count && (Count + Offset) <= _size)
701714
);
702-
return Span<element_type, Count == SPAN_DYNAMIC_EXTENT ? SPAN_DYNAMIC_EXTENT : Count>(
715+
return Span<element_type, Count>(
703716
_data + Offset,
704717
Count == SPAN_DYNAMIC_EXTENT ? _size - Offset : Count
705718
);
@@ -774,6 +787,8 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
774787
*
775788
* @return True if Spans in input have the same size and the same content and
776789
* false otherwise.
790+
*
791+
* @relates Span
777792
*/
778793
template<typename T, typename U, ptrdiff_t LhsExtent, ptrdiff_t RhsExtent>
779794
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)
827842
*
828843
* @return True if arrays in input do not have the same size or the same content
829844
* and false otherwise.
845+
*
846+
* @relates Span
830847
*/
831848
template<typename T, typename U, ptrdiff_t LhsExtent, ptrdiff_t RhsExtent>
832849
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)
876893
*
877894
* @note This helper avoids the typing of template parameter when Span is
878895
* created 'inline'.
896+
*
897+
* @relates Span
879898
*/
880899
template<typename T, size_t Size>
881900
Span<T, Size> make_Span(T (&elements)[Size])
@@ -914,6 +933,8 @@ Span<T, Extent> make_Span(T *elements)
914933
*
915934
* @note This helper avoids the typing of template parameter when Span is
916935
* created 'inline'.
936+
*
937+
* @relates Span
917938
*/
918939
template<typename T>
919940
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])
951972
*
952973
* @note This helper avoids the typing of template parameter when Span is
953974
* created 'inline'.
975+
*
976+
* @relates Span
954977
*/
955978
template<size_t Extent, typename T>
956979
Span<const T, Extent> make_const_Span(const T *elements)
@@ -971,13 +994,19 @@ Span<const T, Extent> make_const_Span(const T *elements)
971994
*
972995
* @note This helper avoids the typing of template parameter when Span is
973996
* created 'inline'.
997+
*
998+
* @relates Span
974999
*/
9751000
template<typename T>
9761001
Span<const T> make_const_Span(T *array_ptr, size_t array_size)
9771002
{
9781003
return Span<const T>(array_ptr, array_size);
9791004
}
9801005

1006+
/**@}*/
1007+
1008+
/**@}*/
1009+
9811010
} // namespace mbed
9821011

9831012
#endif /* MBED_PLATFORM_SPAN_H_ */

0 commit comments

Comments
 (0)