DUNE-FEM (unstable)
A contiguous sequence of elements with static or dynamic extent. More...
#include <dune/common/std/span.hh>
Span constructors | |
template<std::size_t e = extent, std::enable_if_t<(e==dynamic_extent||e==0), int > = 0> | |
constexpr | span () noexcept |
Default construct an empty span. | |
template<class Iter , class U = std::remove_reference_t<decltype(*std::declval<Iter>())>, std::enable_if_t< std::is_convertible_v< U(*)[], element_type(*)[]>, int > = 0> | |
constexpr | span (Iter first, size_type size) |
Constructs a span that is a view over the range [first, first+size) | |
template<class Iter , class U = std::remove_reference_t<decltype(*std::declval<Iter>())>, std::enable_if_t< std::is_convertible_v< U(*)[], element_type(*)[]>, int > = 0> | |
constexpr | span (Iter first, Iter last) |
Constructs a span that is a view over the range [first, last) | |
template<class Range , decltype(std::begin(std::declval< Range >()), std::end(std::declval< Range >()), bool{}) = true, std::enable_if_t< not std::is_array_v< Range >, int > = 0> | |
constexpr | span (Range &range) |
Constructs a span that is a view over the range [range.begin(), range.end()) | |
template<std::size_t N, std::size_t e = extent, std::enable_if_t<(e==Std::dynamic_extent||e==N), int > = 0> | |
constexpr | span (Impl::TypeIdentity_t< element_type >(&data)[N]) noexcept |
Constructs a span that is a view over the C-array. | |
template<class T , size_t N, std::size_t e = extent, std::enable_if_t<(e==Std::dynamic_extent||e==N), int > = 0, std::enable_if_t< std::is_convertible_v< T(*)[], element_type(*)[]>, int > = 0> | |
constexpr | span (std::array< T, N > &arr) noexcept |
Constructs a span that is a view over the array. | |
template<class T , size_t N, std::size_t e = extent, std::enable_if_t<(e==Std::dynamic_extent||e==N), int > = 0, std::enable_if_t< std::is_convertible_v< const T(*)[], element_type(*)[]>, int > = 0> | |
constexpr | span (const std::array< T, N > &arr) noexcept |
Constructs a span that is a view over the const array. | |
template<class E = element_type, std::enable_if_t< std::is_const_v< E >, int > = 0> | |
constexpr | span (std::initializer_list< value_type > il) |
Constructs a span that is a view over the initializer-list. | |
constexpr | span (const span &other) noexcept=default |
Copy constructor. | |
template<class OtherElementType , std::size_t OtherExtent, std::enable_if_t<(extent==Std::dynamic_extent||OtherExtent==Std::dynamic_extent||extent==OtherExtent), int > = 0, std::enable_if_t< std::is_convertible_v< OtherElementType(*)[], element_type(*)[]>, int > = 0> | |
constexpr | span (const span< OtherElementType, OtherExtent > &s) noexcept |
Converting copy constructor. | |
constexpr span & | operator= (const span &other) noexcept=default |
Copy assignment operator. | |
Subspans | |
template<std::size_t Count> | |
constexpr span< element_type, Count > | first () const |
Obtains a subspan consisting of the first Count elements of the sequence. | |
template<std::size_t Count> | |
constexpr span< element_type, Count > | last () const |
Obtains a subspan consisting of the last Count elements of the sequence. | |
template<std::size_t Offset, std::size_t Count = Std::dynamic_extent> | |
constexpr span< element_type, subspan_extent(Offset, Count)> | subspan () const |
Obtains a subspan consisting of Count elements of the sequence starting at Offset . More... | |
constexpr span< element_type, Std::dynamic_extent > | first (size_type count) const |
Obtains a subspan consisting of the first count elements of the sequence. | |
constexpr span< element_type, Std::dynamic_extent > | last (size_type count) const |
Obtains a subspan consisting of the last count elements of the sequence. | |
constexpr span< element_type, Std::dynamic_extent > | subspan (size_type offset, size_type count=Std::dynamic_extent) const |
Obtains a subspan consisting of count elements of the sequence starting at offset . More... | |
Size information | |
constexpr size_type | size_bytes () const noexcept |
Returns the size of the sequence in bytes. | |
constexpr bool | empty () const noexcept |
Checks if the sequence is empty. | |
Detailed Description
class Dune::Std::span< Element, Extent >
A contiguous sequence of elements with static or dynamic extent.
The class template span describes an object that can refer to a contiguous sequence of objects with the first element of the sequence at position zero. A span can either have a static extent, in which case the number of elements in the sequence is known at compile-time and encoded in the type, or a dynamic extent.
If a span has dynamic extent, a typical implementation holds two members: a pointer to Element
and a size. A span with static extent may have only one member: a pointer to Element
.
The implementation is based on the C++ standard working draft N4971 and the documentation provided in cppreference.
Example:
- Template Parameters
-
Element The element type; a complete object type that is not an abstract class type. Extent Specifies number of elements in the sequence, or Std::dynamic_extent
if dynamic.
Member Function Documentation
◆ subspan() [1/2]
|
inlineconstexpr |
Obtains a subspan consisting of Count
elements of the sequence starting at Offset
.
- Note
- If
Count == Std::dynamic_extent
, the subspan starting atOffset
goes until the end of the current span.
References Dune::Std::span< Element, Extent >::data(), and Dune::Std::dynamic_extent.
◆ subspan() [2/2]
|
inlineconstexpr |
Obtains a subspan consisting of count
elements of the sequence starting at offset
.
- Note
- If
count == Std::dynamic_extent
, the subspan starting atoffset
goes until the end of the current span.
The documentation for this class was generated from the following file:
- dune/common/std/span.hh