RTC auf true

Embed: (wiki syntax)

« Back to documentation index

Span< ElementType, SPAN_DYNAMIC_EXTENT > Struct Template Reference

Span< ElementType, SPAN_DYNAMIC_EXTENT > Struct Template Reference
[Span class]

Span specialization that handle dynamic size. More...

#include <Span.h>

Public Types

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

Public Member Functions

 Span ()
 Construct an empty Span.
 Span (pointer ptr, index_type count)
 Construct a Span from a pointer to a buffer and its size.
 Span (pointer first, pointer last)
 Construct a Span from the range [first, last).
template<size_t Count>
 Span (element_type(&elements)[Count])
 Construct a Span from the reference to an array.
template<typename OtherElementType , ptrdiff_t OtherExtent>
 Span (const Span< OtherElementType, OtherExtent > &other)
 Construct a Span object from another Span.
index_type size () const
 Return the size of the array viewed.
bool empty () const
 Return if the sequence viewed is empty or not.
reference operator[] (index_type index) const
 Access to an element of the sequence.
pointer data () const
 Get the raw pointer to the sequence viewed.
template<ptrdiff_t Count>
Span< element_type, Count > first () const
 Create a new Span over the first Count elements of the existing view.
template<ptrdiff_t Count>
Span< element_type, Count > last () const
 Create a new Span over the last Count elements of the existing view.
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.
Span< element_type,
SPAN_DYNAMIC_EXTENT > 
first (index_type count) const
 Create a new Span over the first count elements of the existing view.
Span< element_type,
SPAN_DYNAMIC_EXTENT > 
last (index_type count) const
 Create a new Span over the last count elements of the existing view.
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.

Static Public Attributes

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

Detailed Description

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

Span specialization that handle dynamic size.

Definition at line 507 of file Span.h.


Member Typedef Documentation

typedef ElementType element_type

Type of the element contained.

Definition at line 511 of file Span.h.

typedef ptrdiff_t index_type

Type of the index.

Definition at line 516 of file Span.h.

Pointer to an ElementType.

Definition at line 521 of file Span.h.

Reference to an ElementType.

Definition at line 526 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 541 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 556 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 575 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 593 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 606 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 657 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 630 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 728 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 672 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 741 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 688 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 644 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 620 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 762 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 708 of file Span.h.


Field Documentation

const index_type extent = SPAN_DYNAMIC_EXTENT [static]

Size of the Extent; -1 if dynamic.

Definition at line 531 of file Span.h.