Diag-Client-Lib
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
core_type::Span< T, Extent > Class Template Reference

A view over a contiguous sequence of objects. More...

#include <span.h>

Public Types

using element_type = T
 Type alias for the type of elements in this Span. More...
 
using value_type = typename std::remove_cv< element_type >::type
 Type alias for the type of values in this Span. More...
 
using size_type = std::size_t
 Type alias for the type of parameters that indicate a size or a number of values. More...
 
using difference_type = std::ptrdiff_t
 Type alias for the type of parameters that indicate a difference of indexes into the Span. More...
 
using pointer = element_type *
 Type alias type for a pointer to an element. More...
 
using const_pointer = const element_type *
 Type alias type for a pointer to an const element. More...
 
using reference = element_type &
 Type alias type for a reference to an element. More...
 
using const_reference = const element_type &
 Type alias type for a reference to an const element. More...
 
using iterator = pointer
 The type of an iterator to elements. More...
 
using const_iterator = const_pointer
 The type of a const_iterator to elements. More...
 
using reverse_iterator = std::reverse_iterator< iterator >
 The type of a reverse_iterator to elements. More...
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 The type of a const_reverse_iterator to elements. More...
 

Public Member Functions

template<std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||E==0), bool >::type = true>
constexpr Span () noexcept
 Default constructor. More...
 
constexpr Span (pointer ptr, size_type count)
 Construct a new Span from the given pointer and size. More...
 
constexpr Span (pointer first_elem, pointer last_elem)
 Construct a new Span from the open range between [first_elem, last_elem) More...
 
template<std::size_t N, std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||N==extent) &&details::is_container_element_type_convertible< element_type(&)[N], T >::value, bool >::type = true>
constexpr Span (element_type(&arr)[N]) noexcept
 Construct a new Span from the given raw array. More...
 
template<typename U , std::size_t N, std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||N==extent) &&details::is_container_element_type_convertible< std::array< U, N > &, T >::value, bool >::type = true>
constexpr Span (std::array< U, N > &arr) noexcept
 Construct a new Span from the given std::array. More...
 
template<typename U , std::size_t N, std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||N==extent) &&details::is_container_element_type_convertible< const std::array< U, N > &, T >::value, bool >::type = true>
constexpr Span (const std::array< U, N > &arr) noexcept
 Construct a new Span from the given const std::array. More...
 
template<typename Container , std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent) &&details::is_container_type< Container >::value &&details::is_container_element_type_convertible< Container &, T >::value, bool >::type = true>
constexpr Span (Container &cont) noexcept
 Construct a new Span from the given container. More...
 
template<typename Container , std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent) &&details::is_container_type< Container >::value &&details::is_container_element_type_convertible< Container &, T >::value, bool >::type = true>
constexpr Span (const Container &cont) noexcept
 Construct a new Span from the given const container. More...
 
constexpr Span (const Span &) noexcept=default
 Copy construct a new Span from another instance. More...
 
template<typename U , std::size_t N, typename std::enable_if<(Extent==dynamic_extent||N==dynamic_extent||Extent==N) &&details::is_container_element_type_convertible< U(*)[], T(*)[]>::value >::type = true>
constexpr Span (const Span< U, N > &other_span) noexcept
 Converting constructor. More...
 
 ~Span () noexcept=default
 Destructor. More...
 
constexpr Spanoperator= (const Span &other) noexcept=default
 Copy assignment operator. More...
 
template<std::size_t Count>
constexpr Span< element_type, Count > first () const
 Return a subspan containing only the first elements of this Span. More...
 
constexpr Span< element_type, dynamic_extentfirst (size_type count) const
 Return a subspan containing only the first elements of this Span. More...
 
template<std::size_t Count>
constexpr Span< element_type, Count > last () const
 Return a subspan containing only the last elements of this Span. More...
 
constexpr Span< element_type, dynamic_extentlast (size_type count) const
 Return a subspan containing only the last elements of this Span. More...
 
template<std::size_t Offset, std::size_t Count = dynamic_extent>
constexpr auto subspan () const noexcept -> Span< element_type, Count !=dynamic_extent ? Count :(Extent !=dynamic_extent ? Extent - Offset :dynamic_extent)>
 Return a subspan of this Span. More...
 
constexpr Span< element_type, dynamic_extentsubspan (size_type offset, size_type count=dynamic_extent) const
 Return a subspan of this Span. More...
 
constexpr size_type size () const noexcept
 Return the size of this Span. More...
 
constexpr size_type size_bytes () const noexcept
 Return the size of this Span in bytes. More...
 
constexpr bool empty () const noexcept
 Return whether this Span is empty. More...
 
constexpr reference operator[] (size_type idx) const
 Return a reference to the n-th element of this Span. More...
 
constexpr reference front () const
 Return a reference to the first element of this Span. More...
 
constexpr reference back () const
 Return a reference to the last element of this Span. More...
 
constexpr pointer data () const noexcept
 Return a pointer to the start of the memory block covered by this Span. More...
 
constexpr iterator begin () const noexcept
 Return an iterator pointing to the first element of this Span. More...
 
constexpr iterator end () const noexcept
 Return an iterator pointing past the last element of this Span. More...
 
constexpr const_iterator cbegin () const noexcept
 Return a const_iterator pointing to the first element of this Span. More...
 
constexpr const_iterator cend () const noexcept
 Return a const_iterator pointing past the last element of this Span. More...
 
constexpr reverse_iterator rbegin () const noexcept
 Return a reverse_iterator pointing to the last element of this Span. More...
 
constexpr reverse_iterator rend () const noexcept
 Return a reverse_iterator pointing past the first element of this Span. More...
 
constexpr const_reverse_iterator crbegin () const noexcept
 Return a const_reverse_iterator pointing to the last element of this Span. More...
 
constexpr const_reverse_iterator crend () const noexcept
 Return a const_reverse_iterator pointing past the first element of this Span. More...
 

Static Public Attributes

static constexpr size_type extent = Extent
 A constant reflecting the configured Extent of this Span. More...
 

Private Attributes

details::span_storage< T, Extent > storage_
 The storage of span related data. More...
 

Detailed Description

template<typename T, std::size_t Extent>
class core_type::Span< T, Extent >

A view over a contiguous sequence of objects.

The type T is required to be a complete object type that is not an abstract class type. This class is implemented based on API specification of ara::core::Span from Adaptive Platform Core AUTOSAR AP R21-11

Template Parameters
TThe type of elements in the Span
ExtentThe extent to use for this Span

Definition at line 190 of file span.h.

Member Typedef Documentation

◆ const_iterator

template<typename T , std::size_t Extent>
using core_type::Span< T, Extent >::const_iterator = const_pointer

The type of a const_iterator to elements.

This iterator shall implement the concepts RandomAccessIterator, ContiguousIterator, and ConstexprIterator

Definition at line 244 of file span.h.

◆ const_pointer

template<typename T , std::size_t Extent>
using core_type::Span< T, Extent >::const_pointer = const element_type *

Type alias type for a pointer to an const element.

Definition at line 222 of file span.h.

◆ const_reference

template<typename T , std::size_t Extent>
using core_type::Span< T, Extent >::const_reference = const element_type &

Type alias type for a reference to an const element.

Definition at line 232 of file span.h.

◆ const_reverse_iterator

template<typename T , std::size_t Extent>
using core_type::Span< T, Extent >::const_reverse_iterator = std::reverse_iterator<const_iterator>

The type of a const_reverse_iterator to elements.

Definition at line 254 of file span.h.

◆ difference_type

template<typename T , std::size_t Extent>
using core_type::Span< T, Extent >::difference_type = std::ptrdiff_t

Type alias for the type of parameters that indicate a difference of indexes into the Span.

Definition at line 212 of file span.h.

◆ element_type

template<typename T , std::size_t Extent>
using core_type::Span< T, Extent >::element_type = T

Type alias for the type of elements in this Span.

Definition at line 197 of file span.h.

◆ iterator

template<typename T , std::size_t Extent>
using core_type::Span< T, Extent >::iterator = pointer

The type of an iterator to elements.

This iterator shall implement the concepts RandomAccessIterator, ContiguousIterator, and ConstexprIterator

Definition at line 238 of file span.h.

◆ pointer

template<typename T , std::size_t Extent>
using core_type::Span< T, Extent >::pointer = element_type *

Type alias type for a pointer to an element.

Definition at line 217 of file span.h.

◆ reference

template<typename T , std::size_t Extent>
using core_type::Span< T, Extent >::reference = element_type &

Type alias type for a reference to an element.

Definition at line 227 of file span.h.

◆ reverse_iterator

template<typename T , std::size_t Extent>
using core_type::Span< T, Extent >::reverse_iterator = std::reverse_iterator<iterator>

The type of a reverse_iterator to elements.

Definition at line 249 of file span.h.

◆ size_type

template<typename T , std::size_t Extent>
using core_type::Span< T, Extent >::size_type = std::size_t

Type alias for the type of parameters that indicate a size or a number of values.

Definition at line 207 of file span.h.

◆ value_type

template<typename T , std::size_t Extent>
using core_type::Span< T, Extent >::value_type = typename std::remove_cv<element_type>::type

Type alias for the type of values in this Span.

Definition at line 202 of file span.h.

Constructor & Destructor Documentation

◆ Span() [1/10]

template<typename T , std::size_t Extent>
template<std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||E==0), bool >::type = true>
constexpr core_type::Span< T, Extent >::Span ( )
inlineconstexprnoexcept

Default constructor.

This constructor shall not participate in overload resolution unless (Extent == dynamic_extent || Extent == 0) is true

Definition at line 266 of file span.h.

266 {}

◆ Span() [2/10]

template<typename T , std::size_t Extent>
constexpr core_type::Span< T, Extent >::Span ( pointer  ptr,
size_type  count 
)
inlineconstexpr

Construct a new Span from the given pointer and size.

[ptr, ptr + count) shall be a valid range. If extent is not equal to dynamic_extent, then count shall be equal to Extent

Parameters
[in]ptrThe pointer
[in]countThe number of elements to take from ptr

Definition at line 277 of file span.h.

277  : storage_{ptr, count} {
278  details::CheckIfExpectedOrAbort(Extent == dynamic_extent || count == Extent, "Invalid range", __FILE__, __LINE__);
279  }
details::span_storage< T, Extent > storage_
The storage of span related data.
Definition: span.h:611
void CheckIfExpectedOrAbort(bool cond, const char *message, const std::string_view file_name, int line_no)
Check if the condition is as expected otherwise abort with provided message.
Definition: span.h:46
constexpr std::size_t dynamic_extent
A constant for creating Spans with dynamic sizes.
Definition: span.h:23

References core_type::details::CheckIfExpectedOrAbort(), and core_type::dynamic_extent.

Here is the call graph for this function:

◆ Span() [3/10]

template<typename T , std::size_t Extent>
constexpr core_type::Span< T, Extent >::Span ( pointer  first_elem,
pointer  last_elem 
)
inlineconstexpr

Construct a new Span from the open range between [first_elem, last_elem)

[first_elem, last_elem) shall be a valid range. If extent is not equal to dynamic_extent, then (last_elem - first_elem) shall be equal to extent

Parameters
[in]first_elemThe pointer to the first element
[in]last_elemThe pointer to past the last element

Definition at line 290 of file span.h.

290  : storage_{first_elem, last_elem - first_elem} {
291  details::CheckIfExpectedOrAbort(Extent == dynamic_extent || (last_elem - first_elem) == Extent, "Invalid range",
292  __FILE__, __LINE__);
293  }

References core_type::details::CheckIfExpectedOrAbort(), and core_type::dynamic_extent.

Here is the call graph for this function:

◆ Span() [4/10]

template<typename T , std::size_t Extent>
template<std::size_t N, std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||N==extent) &&details::is_container_element_type_convertible< element_type(&)[N], T >::value, bool >::type = true>
constexpr core_type::Span< T, Extent >::Span ( element_type(&)  arr[N])
inlineexplicitconstexprnoexcept

Construct a new Span from the given raw array.

This constructor shall not participate in overload resolution unless: extent == dynamic_extent || N == extent is true, and std::remove_pointer_t<decltype(std::data(arr))>(*)[] is convertible to T(*)[]

Template Parameters
NThe size of the raw array
Parameters
[in]arrThe raw array

Definition at line 308 of file span.h.

308 : storage_{arr, N} {}

◆ Span() [5/10]

template<typename T , std::size_t Extent>
template<typename U , std::size_t N, std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||N==extent) &&details::is_container_element_type_convertible< std::array< U, N > &, T >::value, bool >::type = true>
constexpr core_type::Span< T, Extent >::Span ( std::array< U, N > &  arr)
inlineexplicitconstexprnoexcept

Construct a new Span from the given std::array.

This constructor shall not participate in overload resolution unless: extent == dynamic_extent || N == extent is true, and std::remove_pointer_t<decltype(std::data(arr))>(*)[] is convertible to T(*)[]

Template Parameters
UThe type of elements within the std::array
NThe size of the raw array
Parameters
[in]arrThe std::array

Definition at line 325 of file span.h.

325 : storage_{arr.data(), N} {}

◆ Span() [6/10]

template<typename T , std::size_t Extent>
template<typename U , std::size_t N, std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||N==extent) &&details::is_container_element_type_convertible< const std::array< U, N > &, T >::value, bool >::type = true>
constexpr core_type::Span< T, Extent >::Span ( const std::array< U, N > &  arr)
inlineexplicitconstexprnoexcept

Construct a new Span from the given const std::array.

This constructor shall not participate in overload resolution unless: extent == dynamic_extent || N == extent is true, and std::remove_pointer_t<decltype(std::data(arr))>(*)[] is convertible to T(*)[]

Template Parameters
UThe type of elements within the std::array
NThe size of the raw array
Parameters
[in]arrThe std::array

Definition at line 343 of file span.h.

343 : storage_{arr.data(), N} {}

◆ Span() [7/10]

template<typename T , std::size_t Extent>
template<typename Container , std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent) &&details::is_container_type< Container >::value &&details::is_container_element_type_convertible< Container &, T >::value, bool >::type = true>
constexpr core_type::Span< T, Extent >::Span ( Container &  cont)
inlineexplicitconstexprnoexcept

Construct a new Span from the given container.

[std::data(cont), std::data(cont) + std::size(cont)) shall be a valid range. This constructor shall not participate in overload resolution unless: extent == dynamic_extent is true, Container is not a specialization of Span, Container is not a specialization of Array, Container is not a specialization of std::array, std::is_array<Container>::value is false, std::data(cont) and std::size(cont) are both well-formed, and std::remove_pointer_t<decltype(ara::core::data(cont))>(*)[] is convertible to T(*)[].

Template Parameters
ContainerThe type of container
Parameters
[in]contThe container

Definition at line 361 of file span.h.

361 : storage_{std::data(cont), std::size(cont)} {}

◆ Span() [8/10]

template<typename T , std::size_t Extent>
template<typename Container , std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent) &&details::is_container_type< Container >::value &&details::is_container_element_type_convertible< Container &, T >::value, bool >::type = true>
constexpr core_type::Span< T, Extent >::Span ( const Container &  cont)
inlineexplicitconstexprnoexcept

Construct a new Span from the given const container.

[std::data(cont), std::data(cont) + std::size(cont)) shall be a valid range. This constructor shall not participate in overload resolution unless: extent == dynamic_extent is true, Container is not a specialization of Span, Container is not a specialization of Array, Container is not a specialization of std::array, std::is_array<Container>::value is false, std::data(cont) and std::size(cont) are both well-formed, and std::remove_pointer_t<decltype(ara::core::data(cont))>(*)[] is convertible to T(*)[].

Template Parameters
ContainerThe type of container
Parameters
[in]contThe container

Definition at line 379 of file span.h.

379 : storage_{std::data(cont), std::size(cont)} {}

◆ Span() [9/10]

template<typename T , std::size_t Extent>
constexpr core_type::Span< T, Extent >::Span ( const Span< T, Extent > &  )
constexprdefaultnoexcept

Copy construct a new Span from another instance.

◆ Span() [10/10]

template<typename T , std::size_t Extent>
template<typename U , std::size_t N, typename std::enable_if<(Extent==dynamic_extent||N==dynamic_extent||Extent==N) &&details::is_container_element_type_convertible< U(*)[], T(*)[]>::value >::type = true>
constexpr core_type::Span< T, Extent >::Span ( const Span< U, N > &  other_span)
inlineexplicitconstexprnoexcept

Converting constructor.

This ctor allows construction of a cv-qualified Span from a normal Span, and also of a dynamic_extent-Span<> from a static extent-one. This constructor shall not participate in overload resolution unless: Extent == dynamic_extent || Extent == N is true, U(*)[] is convertible to T(*)[].

Template Parameters
UThe type of elements within the other Span
NThe Extent of the other Span
Parameters
[in]other_spanThe other Span instance

Definition at line 402 of file span.h.

402 : storage_{other_span.data(), other_span.size()} {}

◆ ~Span()

template<typename T , std::size_t Extent>
core_type::Span< T, Extent >::~Span ( )
defaultnoexcept

Destructor.

Member Function Documentation

◆ back()

template<typename T , std::size_t Extent>
constexpr reference core_type::Span< T, Extent >::back ( ) const
inlineconstexpr

Return a reference to the last element of this Span.

The behavior of this function is undefined if empty() is true

Returns
The reference

Definition at line 548 of file span.h.

548  {
549  details::CheckIfExpectedOrAbort(!empty(), "Span is empty", __FILE__, __LINE__);
550  return *(data() + (size() - 1));
551  }
constexpr pointer data() const noexcept
Return a pointer to the start of the memory block covered by this Span.
Definition: span.h:557
constexpr size_type size() const noexcept
Return the size of this Span.
Definition: span.h:508
constexpr bool empty() const noexcept
Return whether this Span is empty.
Definition: span.h:520

References core_type::details::CheckIfExpectedOrAbort(), core_type::Span< T, Extent >::data(), core_type::Span< T, Extent >::empty(), and core_type::Span< T, Extent >::size().

Here is the call graph for this function:

◆ begin()

template<typename T , std::size_t Extent>
constexpr iterator core_type::Span< T, Extent >::begin ( ) const
inlineconstexprnoexcept

Return an iterator pointing to the first element of this Span.

Returns
The iterator

Definition at line 563 of file span.h.

563 { return data(); }

References core_type::Span< T, Extent >::data().

Referenced by core_type::Span< T, Extent >::cbegin(), core_type::Span< T, Extent >::crend(), and core_type::Span< T, Extent >::rend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cbegin()

template<typename T , std::size_t Extent>
constexpr const_iterator core_type::Span< T, Extent >::cbegin ( ) const
inlineconstexprnoexcept

Return a const_iterator pointing to the first element of this Span.

Returns
The const_iterator

Definition at line 575 of file span.h.

575 { return const_iterator(begin()); }
const_pointer const_iterator
The type of a const_iterator to elements.
Definition: span.h:244
constexpr iterator begin() const noexcept
Return an iterator pointing to the first element of this Span.
Definition: span.h:563

References core_type::Span< T, Extent >::begin().

Here is the call graph for this function:

◆ cend()

template<typename T , std::size_t Extent>
constexpr const_iterator core_type::Span< T, Extent >::cend ( ) const
inlineconstexprnoexcept

Return a const_iterator pointing past the last element of this Span.

Returns
The const_iterator

Definition at line 581 of file span.h.

581 { return const_iterator(end()); }
constexpr iterator end() const noexcept
Return an iterator pointing past the last element of this Span.
Definition: span.h:569

References core_type::Span< T, Extent >::end().

Here is the call graph for this function:

◆ crbegin()

template<typename T , std::size_t Extent>
constexpr const_reverse_iterator core_type::Span< T, Extent >::crbegin ( ) const
inlineconstexprnoexcept

Return a const_reverse_iterator pointing to the last element of this Span.

Returns
The const_reverse_iterator

Definition at line 599 of file span.h.

599 { return const_reverse_iterator(end()); }
std::reverse_iterator< const_iterator > const_reverse_iterator
The type of a const_reverse_iterator to elements.
Definition: span.h:254

References core_type::Span< T, Extent >::end().

Here is the call graph for this function:

◆ crend()

template<typename T , std::size_t Extent>
constexpr const_reverse_iterator core_type::Span< T, Extent >::crend ( ) const
inlineconstexprnoexcept

Return a const_reverse_iterator pointing past the first element of this Span.

Returns
The const_reverse_iterator

Definition at line 605 of file span.h.

605 { return const_reverse_iterator(begin()); }

References core_type::Span< T, Extent >::begin().

Here is the call graph for this function:

◆ data()

template<typename T , std::size_t Extent>
constexpr pointer core_type::Span< T, Extent >::data ( ) const
inlineconstexprnoexcept

◆ empty()

template<typename T , std::size_t Extent>
constexpr bool core_type::Span< T, Extent >::empty ( ) const
inlineconstexprnoexcept

Return whether this Span is empty.

Returns
True if this Span contains 0 elements, False otherwise

Definition at line 520 of file span.h.

520 { return size() == 0u; }

References core_type::Span< T, Extent >::size().

Referenced by core_type::Span< T, Extent >::back(), and core_type::Span< T, Extent >::front().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end()

template<typename T , std::size_t Extent>
constexpr iterator core_type::Span< T, Extent >::end ( ) const
inlineconstexprnoexcept

Return an iterator pointing past the last element of this Span.

Returns
The iterator

Definition at line 569 of file span.h.

569 { return data() + size(); }

References core_type::Span< T, Extent >::data(), and core_type::Span< T, Extent >::size().

Referenced by core_type::Span< T, Extent >::cend(), core_type::Span< T, Extent >::crbegin(), and core_type::Span< T, Extent >::rbegin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ first() [1/2]

template<typename T , std::size_t Extent>
template<std::size_t Count>
constexpr Span<element_type, Count> core_type::Span< T, Extent >::first ( ) const
inlineconstexpr

Return a subspan containing only the first elements of this Span.

The implementation shall ensure that (Count <= Extent) is true. The behavior of this function is undefined if (Count > size()).

Template Parameters
CountThe number of elements to take over
Returns
The subspan

Definition at line 423 of file span.h.

423  {
424  details::CheckIfExpectedOrAbort(Count <= size(), "Count > size()", __FILE__, __LINE__);
425  return Span{data(), Count};
426  }
constexpr Span() noexcept
Default constructor.
Definition: span.h:266

References core_type::details::CheckIfExpectedOrAbort(), core_type::Span< T, Extent >::data(), and core_type::Span< T, Extent >::size().

Here is the call graph for this function:

◆ first() [2/2]

template<typename T , std::size_t Extent>
constexpr Span<element_type, dynamic_extent> core_type::Span< T, Extent >::first ( size_type  count) const
inlineconstexpr

Return a subspan containing only the first elements of this Span.

The behavior of this function is undefined if (count > size())

Parameters
[in]countThe number of elements to take over
Returns
The subspan

Definition at line 435 of file span.h.

435  {
436  details::CheckIfExpectedOrAbort(count <= size(), "Count > size()", __FILE__, __LINE__);
437  return Span{data(), count};
438  }

References core_type::details::CheckIfExpectedOrAbort(), core_type::Span< T, Extent >::data(), and core_type::Span< T, Extent >::size().

Here is the call graph for this function:

◆ front()

template<typename T , std::size_t Extent>
constexpr reference core_type::Span< T, Extent >::front ( ) const
inlineconstexpr

Return a reference to the first element of this Span.

The behavior of this function is undefined if empty() is true

Returns
The reference

Definition at line 538 of file span.h.

538  {
539  details::CheckIfExpectedOrAbort(!empty(), "Span is empty", __FILE__, __LINE__);
540  return *(data());
541  }

References core_type::details::CheckIfExpectedOrAbort(), core_type::Span< T, Extent >::data(), and core_type::Span< T, Extent >::empty().

Here is the call graph for this function:

◆ last() [1/2]

template<typename T , std::size_t Extent>
template<std::size_t Count>
constexpr Span<element_type, Count> core_type::Span< T, Extent >::last ( ) const
inlineconstexpr

Return a subspan containing only the last elements of this Span.

The implementation shall ensure that (Count <= Extent) is true. The behavior of this function is undefined if (Count > size()).

Template Parameters
CountThe number of elements to take over
Returns
The subspan

Definition at line 449 of file span.h.

449  {
450  details::CheckIfExpectedOrAbort(Count <= size(), "Count > size()", __FILE__, __LINE__);
451  return Span{data() + (size() - Count), Count};
452  }

References core_type::details::CheckIfExpectedOrAbort(), core_type::Span< T, Extent >::data(), and core_type::Span< T, Extent >::size().

Here is the call graph for this function:

◆ last() [2/2]

template<typename T , std::size_t Extent>
constexpr Span<element_type, dynamic_extent> core_type::Span< T, Extent >::last ( size_type  count) const
inlineconstexpr

Return a subspan containing only the last elements of this Span.

The behavior of this function is undefined if (count > size())

Parameters
[in]countThe number of elements to take over
Returns
The subspan

Definition at line 461 of file span.h.

461  {
462  details::CheckIfExpectedOrAbort(count <= size(), "count > size()", __FILE__, __LINE__);
463  return Span{data() + (size() - count), count};
464  }

References core_type::details::CheckIfExpectedOrAbort(), core_type::Span< T, Extent >::data(), and core_type::Span< T, Extent >::size().

Here is the call graph for this function:

◆ operator=()

template<typename T , std::size_t Extent>
constexpr Span& core_type::Span< T, Extent >::operator= ( const Span< T, Extent > &  other)
constexprdefaultnoexcept

Copy assignment operator.

◆ operator[]()

template<typename T , std::size_t Extent>
constexpr reference core_type::Span< T, Extent >::operator[] ( size_type  idx) const
inlineconstexpr

Return a reference to the n-th element of this Span.

Parameters
[in]idxThe index into this Span
Returns
The reference

Definition at line 528 of file span.h.

528  {
529  details::CheckIfExpectedOrAbort(idx < size(), "idx > size()", __FILE__, __LINE__);
530  return *(data() + idx);
531  }

References core_type::details::CheckIfExpectedOrAbort(), core_type::Span< T, Extent >::data(), and core_type::Span< T, Extent >::size().

Here is the call graph for this function:

◆ rbegin()

template<typename T , std::size_t Extent>
constexpr reverse_iterator core_type::Span< T, Extent >::rbegin ( ) const
inlineconstexprnoexcept

Return a reverse_iterator pointing to the last element of this Span.

Returns
The reverse_iterator

Definition at line 587 of file span.h.

587 { return reverse_iterator(end()); }
std::reverse_iterator< iterator > reverse_iterator
The type of a reverse_iterator to elements.
Definition: span.h:249

References core_type::Span< T, Extent >::end().

Here is the call graph for this function:

◆ rend()

template<typename T , std::size_t Extent>
constexpr reverse_iterator core_type::Span< T, Extent >::rend ( ) const
inlineconstexprnoexcept

Return a reverse_iterator pointing past the first element of this Span.

Returns
The reverse_iterator

Definition at line 593 of file span.h.

593 { return reverse_iterator(begin()); }

References core_type::Span< T, Extent >::begin().

Here is the call graph for this function:

◆ size()

template<typename T , std::size_t Extent>
constexpr size_type core_type::Span< T, Extent >::size ( ) const
inlineconstexprnoexcept

◆ size_bytes()

template<typename T , std::size_t Extent>
constexpr size_type core_type::Span< T, Extent >::size_bytes ( ) const
inlineconstexprnoexcept

Return the size of this Span in bytes.

Returns
The number of bytes covered by this Span

Definition at line 514 of file span.h.

514 { return size() * sizeof(element_type); }
T element_type
Type alias for the type of elements in this Span.
Definition: span.h:197

References core_type::Span< T, Extent >::size().

Here is the call graph for this function:

◆ subspan() [1/2]

template<typename T , std::size_t Extent>
template<std::size_t Offset, std::size_t Count = dynamic_extent>
constexpr auto core_type::Span< T, Extent >::subspan ( ) const -> Span<element_type, Count != dynamic_extent ? Count : (Extent != dynamic_extent ? Extent - Offset : dynamic_extent)>
inlineconstexprnoexcept

Return a subspan of this Span.

The second template argument of the returned Span type is: Count != dynamic_extent ? Count : (Extent != dynamic_extent ? Extent - Offset : dynamic_extent) The implementation shall ensure that (Offset <= Extent && (Count == dynamic_extent || Count <= Extent - Offset)) is true. The behavior of this function is undefined unless (Offset <= size() && (Count == dynamic_extent || Count <= size() - Offset)) is true.

Template Parameters
OffsetThe offset into this Span from which to start
CountThe number of elements to take over
Returns
The subspan

Definition at line 479 of file span.h.

481  : (Extent != dynamic_extent ? Extent - Offset : dynamic_extent)> {
482  details::CheckIfExpectedOrAbort((Offset <= size() && (Count == dynamic_extent || Count <= size() - Offset)),
483  "(Offset <= size() && (Count == dynamic_extent || Count <= size() - Offset))",
484  __FILE__, __LINE__);
485  return Span{data() + Offset, Count != dynamic_extent ? Count : size() - Offset};
486  }

References core_type::details::CheckIfExpectedOrAbort(), core_type::Span< T, Extent >::data(), core_type::dynamic_extent, and core_type::Span< T, Extent >::size().

Here is the call graph for this function:

◆ subspan() [2/2]

template<typename T , std::size_t Extent>
constexpr Span<element_type, dynamic_extent> core_type::Span< T, Extent >::subspan ( size_type  offset,
size_type  count = dynamic_extent 
) const
inlineconstexpr

Return a subspan of this Span.

The behavior of this function is undefined unless (offset <= size() && (count == dynamic_extent || count <= size() - offset)) is true

Parameters
[in]offsetThe offset into this Span from which to start
[in]countThe number of elements to take over
Returns
The subspan

Definition at line 497 of file span.h.

497  {
498  details::CheckIfExpectedOrAbort((offset <= size() && (count == dynamic_extent || count <= size() - offset)),
499  "(offset <= size() && (count == dynamic_extent || count <= size() - offset))",
500  __FILE__, __LINE__);
501  return {data() + offset, count == dynamic_extent ? size() - offset : count};
502  }

References core_type::details::CheckIfExpectedOrAbort(), core_type::Span< T, Extent >::data(), core_type::dynamic_extent, and core_type::Span< T, Extent >::size().

Here is the call graph for this function:

Member Data Documentation

◆ extent

template<typename T , std::size_t Extent>
constexpr size_type core_type::Span< T, Extent >::extent = Extent
staticconstexpr

A constant reflecting the configured Extent of this Span.

Definition at line 259 of file span.h.

◆ storage_

template<typename T , std::size_t Extent>
details::span_storage<T, Extent> core_type::Span< T, Extent >::storage_
private

The storage of span related data.

Definition at line 611 of file span.h.

Referenced by core_type::Span< T, Extent >::data(), and core_type::Span< T, Extent >::size().


The documentation for this class was generated from the following file: