Mistake on this page?
Report an issue in GitHub or email us
Public Types | Public Member Functions | Static Public Attributes
Span< ElementType, SPAN_DYNAMIC_EXTENT > Struct Template Reference

Span specialization that handle dynamic size. More...

#include <Span.h>

Public Types

typedef ElementType element_type
 Type of the element contained. More...
 
typedef ptrdiff_t index_type
 Type of the index. More...
 
typedef element_typepointer
 Pointer to an ElementType. More...
 
typedef element_typereference
 Reference to an ElementType. More...
 

Public Member Functions

 Span ()
 Construct an empty Span. More...
 
 Span (pointer ptr, index_type count)
 Construct a Span from a pointer to a buffer and its size. More...
 
 Span (pointer first, pointer last)
 Construct a Span from the range [first, last). More...
 
template<size_t Count>
 Span (element_type(&elements)[Count])
 Construct a Span from the reference to an array. More...
 
template<typename OtherElementType , ptrdiff_t OtherExtent>
 Span (const Span< OtherElementType, OtherExtent > &other)
 Construct a Span object from another Span. More...
 
index_type size () const
 Return the size of the array viewed. More...
 
bool empty () const
 Return if the sequence viewed is empty or not. More...
 
reference operator[] (index_type index) const
 Access to an element of the sequence. More...
 
pointer data () const
 Get the raw pointer to the sequence viewed. More...
 
template<ptrdiff_t Count>
Span< element_type, Count > first () const
 Create a new Span over the first Count elements of the existing view. More...
 
template<ptrdiff_t Count>
Span< element_type, Count > last () const
 Create a new Span over the last Count elements of the existing view. More...
 
template<std::ptrdiff_t Offset, std::ptrdiff_t Count>
Span< element_type, Count > subspan () const
 Create a subspan that is a view other Count elements; the view starts at element Offset. More...
 
Span< element_type, SPAN_DYNAMIC_EXTENT > first (index_type count) const
 Create a new Span over the first count elements of the existing view. More...
 
Span< element_type, SPAN_DYNAMIC_EXTENT > last (index_type count) const
 Create a new Span over the last count elements of the existing view. More...
 
Span< element_type, SPAN_DYNAMIC_EXTENT > subspan (index_type offset, index_type count=SPAN_DYNAMIC_EXTENT) const
 Create a subspan that is a view of other count elements; the view starts at element offset. More...
 

Static Public Attributes

static const index_type extent = SPAN_DYNAMIC_EXTENT
 Size of the Extent; -1 if dynamic. More...
 

Detailed Description

template<typename ElementType>
struct mbed::Span< ElementType, SPAN_DYNAMIC_EXTENT >

Span specialization that handle dynamic size.

Definition at line 516 of file Span.h.

Member Typedef Documentation

typedef ElementType element_type

Type of the element contained.

Definition at line 520 of file Span.h.

typedef ptrdiff_t index_type

Type of the index.

Definition at line 525 of file Span.h.

Pointer to an ElementType.

Definition at line 530 of file Span.h.

Reference to an ElementType.

Definition at line 535 of file Span.h.

Constructor & Destructor Documentation

Span ( )

Construct an empty Span.

Postcondition
a call to size() returns 0, and data() returns NULL.
Note
This function is not accessible if Extent != SPAN_DYNAMIC_EXTENT or Extent != 0 .

Definition at line 550 of file Span.h.

Span ( pointer  ptr,
index_type  count 
)

Construct a Span from a pointer to a buffer and its size.

Parameters
ptrPointer to the beginning of the data viewed.
countNumber of elements viewed.
Precondition
[ptr, ptr + count) must be be a valid range.
count must be equal to extent.
Postcondition
a call to size() returns count, and data() returns ptr.

Definition at line 565 of file Span.h.

Span ( pointer  first,
pointer  last 
)

Construct a Span from the range [first, last).

Parameters
firstPointer to the beginning of the data viewed.
lastEnd of the range (element after the last element).
Precondition
[first, last) must be be a valid range.
first <= last.
Postcondition
a call to size() returns the result of (last - first), and data() returns first.

Definition at line 584 of file Span.h.

Span ( element_type(&)  elements[Count])

Construct a Span from the reference to an array.

Parameters
elementsReference to the array viewed.
Template Parameters
CountNumber of elements of T presents in the array.
Postcondition
a call to size() returns Count, and data() returns a pointer to elements.

Definition at line 604 of file Span.h.

Span ( const Span< OtherElementType, OtherExtent > &  other)

Construct a Span object from another Span.

Parameters
otherThe Span object used to construct this.
Note
For Span with a positive extent, this function is not accessible.
OtherElementType(*)[] must be convertible to ElementType(*)[].

Definition at line 617 of file Span.h.

Member Function Documentation

pointer data ( ) const

Get the raw pointer to the sequence viewed.

Returns
The raw pointer to the first element viewed.

Definition at line 669 of file Span.h.

bool empty ( ) const

Return if the sequence viewed is empty or not.

Returns
true if the sequence is empty and false otherwise.

Definition at line 642 of file Span.h.

Span<element_type, Count> first ( ) const

Create a new Span over the first Count elements of the existing view.

Template Parameters
CountThe number of elements viewed by the new Span.
Returns
A new Span over the first Count elements.
Precondition
Count >= 0 && Count <= size().

Definition at line 684 of file Span.h.

Span<element_type, SPAN_DYNAMIC_EXTENT> first ( index_type  count) const

Create a new Span over the first count elements of the existing view.

Parameters
countThe number of elements viewed by the new Span.
Returns
A new Span over the first count elements.

Definition at line 740 of file Span.h.

Span<element_type, Count> last ( ) const

Create a new Span over the last Count elements of the existing view.

Template Parameters
CountThe number of elements viewed by the new Span.
Returns
A new Span over the last Count elements.
Precondition
Count >= 0 && Count <= size().

Definition at line 700 of file Span.h.

Span<element_type, SPAN_DYNAMIC_EXTENT> last ( index_type  count) const

Create a new Span over the last count elements of the existing view.

Parameters
countThe number of elements viewed by the new Span.
Returns
A new Span over the last count elements.

Definition at line 753 of file Span.h.

reference operator[] ( index_type  index) const

Access to an element of the sequence.

Parameters
indexElement index to access.
Returns
A reference to the element at the index specified in input.
Precondition
index is less than size().

Definition at line 656 of file Span.h.

index_type size ( ) const

Return the size of the array viewed.

Returns
The number of elements present in the array viewed.

Definition at line 632 of file Span.h.

Span<element_type, Count> subspan ( ) const

Create a subspan that is a view other Count elements; the view starts at element Offset.

Template Parameters
OffsetThe offset of the first element viewed by the subspan.
CountThe number of elements present in the subspan. If Count is equal to SPAN_DYNAMIC_EXTENT, then a Span starting at offset and containing the rest of the elements is returned.
Returns
A subspan of this starting at Offset and Count long.

Definition at line 720 of file Span.h.

Span<element_type, SPAN_DYNAMIC_EXTENT> subspan ( index_type  offset,
index_type  count = SPAN_DYNAMIC_EXTENT 
) const

Create a subspan that is a view of other count elements; the view starts at element offset.

Parameters
offsetThe offset of the first element viewed by the subspan.
countThe number of elements present in the subspan. If Count is equal to SPAN_DYNAMIC_EXTENT, then a Span starting at offset and containing the rest of the elements is returned.
Returns
A subspan of this starting at offset and count long.

Definition at line 774 of file Span.h.

Field Documentation

const index_type extent = SPAN_DYNAMIC_EXTENT
static

Size of the Extent; -1 if dynamic.

Definition at line 540 of file Span.h.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.