|
KaMPIng 0.2.0
Flexible and (near) zero-overhead C++ bindings for MPI
|
A span modeled after C++20's std::span.
More...
#include <span.hpp>
Public Types | |
| using | element_type = T |
Element type; i.e. T. | |
| using | value_type = std::remove_cv_t<T> |
Value type; i.e. T with volatile and const qualifiers removed. | |
| using | size_type = size_t |
| The type used for the size of the span. | |
| using | difference_type = std::ptrdiff_t |
| The type used for the difference between two elements in the span. | |
| using | pointer = T* |
| The type of a pointer to a single elements in the span. | |
| using | const_pointer = T const* |
| The type of a const pointer to a single elements in the span. | |
| using | reference = T& |
| The type of a reference to a single elements in the span. | |
| using | const_reference = T const& |
| The type of a const reference to a single elements in the span. | |
| using | iterator = pointer |
| The type of an iterator to a single elements in the span. | |
| using | reverse_iterator |
| The type of a reverse iterator to a single elements in the span. | |
Public Member Functions | |
| constexpr | Span () noexcept |
Default constructor for an empty span. The pointer is set to nullptr and the size to 0. | |
| template<typename It > | |
| constexpr | Span (It first, size_type size) |
Constructor for a span from an iterator of type It and a size. | |
| template<typename It > | |
| constexpr | Span (It first, It last) |
Constructs a span that is a view over the range [first, last); the resulting span has data() == kamping::internal::to_address(first) and size() == last-first. | |
| template<typename Range > | |
| constexpr | Span (Range &&range) |
Constructs a span that is a view over the range range. The resulting span has data() == std::data(range) and size() == std::size(). | |
| constexpr pointer | data () const noexcept |
| Get access to the underlying memory. | |
| constexpr iterator | begin () const noexcept |
| Get iterator pointing to the first element of the span. | |
| constexpr iterator | end () const noexcept |
| Get iterator pointing past the last element of the span. | |
| constexpr reverse_iterator | rbegin () const noexcept |
| Get a reverse iterator pointing to the first element of the reversed span. | |
| constexpr reverse_iterator | rend () const noexcept |
| Get a reverse iterator pointing to the last element of the reversed span. | |
| constexpr reference | front () const noexcept |
| Access the first element of the span. | |
| constexpr reference | back () const noexcept |
| Access the last element of the span. | |
| constexpr reference | operator[] (size_type idx) const noexcept |
Access the element at index idx. | |
| constexpr size_type | size () const noexcept |
| Returns the number of elements in the Span. | |
| constexpr size_type | size_bytes () const noexcept |
| Return the number of bytes occupied by the elements in the Span. | |
| constexpr bool | empty () const noexcept |
| Check if the Span is empty. | |
| constexpr Span | first (size_type count) const |
Obtain a span that is a view over the first count elements of the span. | |
| constexpr Span | last (size_type count) const |
Obtain a span that is a view over the last count elements of the span. | |
| constexpr Span | subspan (size_type offset, size_type count) const |
Obtain a span that is a view over the span elements in the range [offset, offset + count). | |
Protected Attributes | |
| pointer | _ptr |
| Pointer to the data referred to by Span. | |
| size_type | _size |
| Number of elements of type T referred to by Span. | |
A span modeled after C++20's std::span.
Since KaMPIng needs to be C++17 compatible and std::span is part of C++20, we need our own implementation of the above-described functionality.
| T | type for which the span is defined. |
| using kamping::Span< T >::reverse_iterator |
The type of a reverse iterator to a single elements in the span.
|
inlineconstexpr |
Constructor for a span from an iterator of type It and a size.
| first | Iterator pointing to the first element of the span. |
| size | The number of elements in the span. |
| It | The iterator type. |
|
inlineconstexpr |
Constructs a span that is a view over the range [first, last); the resulting span has data() == kamping::internal::to_address(first) and size() == last-first.
If [first, last) is not a valid range, or if It does not model a C++20 contiguous iterator, the behavior is undefined. This is analogous to the behavior of std::span.
| first | begin iterator of the range |
| last | end iterator of the range |
| It | the iterator type. |
|
inlineconstexpr |
Constructs a span that is a view over the range range. The resulting span has data() == std::data(range) and size() == std::size().
If range does not model a C++20 contiguous range, the behavior is undefined. This is analogous to the behavior of std::span.
| range | The range. |
| Range | The range type. |
|
inlineconstexprnoexcept |
Get iterator pointing to the first element of the span.
|
inlineconstexprnoexcept |
Get access to the underlying memory.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Get iterator pointing past the last element of the span.
|
inlineconstexprnoexcept |
Returns the number of elements in the Span.
|
inlineconstexprnoexcept |
Return the number of bytes occupied by the elements in the Span.
|
inlineconstexpr |
Obtain a span that is a view over the span elements in the range [offset, offset + count).
| offset | The offset of the first element of the span. |
| count | The number of elements in the span. |