|
template<std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||E<=0), int >::type = 0> |
constexpr | span () noexcept |
|
PRECICE_SPAN_CONSTEXPR11 | span (pointer ptr, size_type count) |
|
PRECICE_SPAN_CONSTEXPR11 | span (pointer first_elem, pointer last_elem) |
|
template<std::size_t N, std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||N==E) &&detail::is_container_element_type_compatible< element_type(&)[N], ElementType >::value, int >::type = 0> |
constexpr | span (element_type(&arr)[N]) noexcept |
|
template<typename T , std::size_t N, std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||N==E) &&detail::is_container_element_type_compatible< std::array< T, N > &, ElementType >::value, int >::type = 0> |
PRECICE_SPAN_ARRAY_CONSTEXPR | span (std::array< T, N > &arr) noexcept |
|
template<typename T , std::size_t N, std::size_t E = Extent, typename std::enable_if<(E==dynamic_extent||N==E) &&detail::is_container_element_type_compatible< const std::array< T, N > &, ElementType >::value, int >::type = 0> |
PRECICE_SPAN_ARRAY_CONSTEXPR | span (const std::array< T, N > &arr) noexcept |
|
template<typename Container , std::size_t E = Extent, typename std::enable_if< E==dynamic_extent &&detail::is_container< Container >::value &&detail::is_container_element_type_compatible< Container &, ElementType >::value, int >::type = 0> |
constexpr | span (Container &cont) |
|
template<typename Container , std::size_t E = Extent, typename std::enable_if< E==dynamic_extent &&detail::is_container< Container >::value &&detail::is_container_element_type_compatible< const Container &, ElementType >::value, int >::type = 0> |
constexpr | span (const Container &cont) |
|
constexpr | span (const span &other) noexcept=default |
|
template<typename OtherElementType , std::size_t OtherExtent, typename std::enable_if<(Extent==dynamic_extent||OtherExtent==dynamic_extent||Extent==OtherExtent) &&std::is_convertible< OtherElementType(*)[], ElementType(*)[]>::value, int >::type = 0> |
constexpr | span (const span< OtherElementType, OtherExtent > &other) noexcept |
|
| ~span () noexcept=default |
|
PRECICE_SPAN_CONSTEXPR_ASSIGN span & | operator= (const span &other) noexcept=default |
|
template<typename T , std::size_t E = Extent, typename std::enable_if< E==dynamic_extent &&(std::is_same< T, const char * >::value||std::is_same< T, char * >::value), int >::type = 0> |
| span (T cstring) |
|
template<std::size_t Count> |
PRECICE_SPAN_CONSTEXPR11 span< element_type, Count > | first () const |
|
template<std::size_t Count> |
PRECICE_SPAN_CONSTEXPR11 span< element_type, Count > | last () const |
|
template<std::size_t Offset, std::size_t Count = dynamic_extent> |
PRECICE_SPAN_CONSTEXPR11 subspan_return_t< Offset, Count > | subspan () const |
|
PRECICE_SPAN_CONSTEXPR11 span< element_type, dynamic_extent > | first (size_type count) const |
|
PRECICE_SPAN_CONSTEXPR11 span< element_type, dynamic_extent > | last (size_type count) const |
|
PRECICE_SPAN_CONSTEXPR11 span< element_type, dynamic_extent > | subspan (size_type offset, size_type count=dynamic_extent) const |
|
constexpr size_type | size () const noexcept |
|
constexpr size_type | size_bytes () const noexcept |
|
PRECICE_SPAN_NODISCARD constexpr bool | empty () const noexcept |
|
PRECICE_SPAN_CONSTEXPR11 reference | operator[] (size_type idx) const |
|
PRECICE_SPAN_CONSTEXPR11 reference | front () const |
|
PRECICE_SPAN_CONSTEXPR11 reference | back () const |
|
constexpr pointer | data () const noexcept |
|
constexpr iterator | begin () const noexcept |
|
constexpr iterator | end () const noexcept |
|
PRECICE_SPAN_ARRAY_CONSTEXPR reverse_iterator | rbegin () const noexcept |
|
PRECICE_SPAN_ARRAY_CONSTEXPR reverse_iterator | rend () const noexcept |
|
template<typename ElementType,
std::size_t Extent>
class precice::span< ElementType, Extent >
A C++ 11 implementation of the non-owning C++20 std::span type.
- Copyright
- Copyright Tristan Brindle 2018.
A span represents a non-owning view into a contiguous block of memory of a known size. This view can be mutable or const, depending on the type.
A simple mental model is an object that holds a pointer and size, so it knows how many elements it is allowed to access after the initial pointer. You can imagine a span<double>
to look like this:
}
A C++ 11 implementation of the non-owning C++20 std::span type.
constexpr iterator begin() const noexcept
constexpr size_type size() const noexcept
This type can also be read-only aka const
. You can imagine a span<const double>
to look like this:
It can be constructed from:
- A pointer and size
- A pointer to first element and pointer to one past the last element
- A C-style array
char[10]
- A C++ STL arrays
std::array<char,10>
- A contiguous range with size
end(R) - begin(R)
, such as a std::vector
- Note
- This version contains an additional constructor for
const char *
-style C strings, allowing the span to mimic C++17 std::string_view.
Definition at line 284 of file span.hpp.