template<typename type_t,
xtd::usize extent = xtd::dynamic_extent>
class xtd::span< type_t, extent >
Represents a non-owning view over a contiguous sequence of objects.
- Definition
template<typename type_t, xtd::usize extent = dynamic_extent>
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
constexpr span()
Creates an empty xtd::span whose xtd::span::data is null and xtd::span::size is 0.
Definition span.hpp:91
- Header
-
- Namespace
- xtd
- Library
- xtd.core
- Examples
- Create a span from memory.
#include <xtd/xtd>
auto main() -> int {
auto memory_pointer = new byte[100];
auto memory_span =
span(memory_pointer, 100);
for (auto ctr = 0_z; ctr < memory_span.length(); ++ctr)
memory_span[ctr] =
data++;
auto array_sum = 0;
for (auto value : memory_span)
array_sum += value;
delete[] memory_pointer;
}
static auto write_line() -> void
Writes the current line terminator to the standard output stream using the specified format informati...
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition span.hpp:224
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:197
Create a span over an array.
#include <xtd/xtd>
auto main() -> int {
auto array_span =
span(bytes);
for (auto ctr = 0_z; ctr < array_span.length(); ++ctr)
array_span[ctr] =
data++;
auto array_sum = 0;
for (auto value : bytes)
array_sum += value;
}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
|
| template<xtd::usize count = 0> |
| constexpr | span () |
| | Creates an empty xtd::span whose xtd::span::data is null and xtd::span::size is 0.
|
| template<typename iterator_t> |
| constexpr | span (iterator_t first, iterator_t last) |
| | Creates an xtd::span with specified iterators.
|
| template<xtd::usize len> |
| constexpr | span (element_type(&array)[len]) noexcept |
| | Creates an xtd::span with specified native array.
|
| template<typename array_type_t, xtd::usize len> |
| constexpr | span (const std::array< array_type_t, len > &array) noexcept |
| | Creates an xtd::span with specified std::array.
|
| template<typename array_type_t, xtd::usize len> |
| constexpr | span (std::array< array_type_t, len > &array) noexcept |
| | Creates an xtd::span with specified std::array.
|
| template<typename array_type_t> |
| constexpr | span (const xtd::array< array_type_t > &items) |
| | Creates an xtd::span with specified collection and count.
|
| template<typename array_type_t> |
| constexpr | span (xtd::array< array_type_t > &items) |
| | Creates an xtd::span with specified collection and count.
|
| template<typename range_t> |
| constexpr | span (range_t &&range) noexcept |
| | Creates an xtd::span with specified range.
|
| constexpr | span (std::initializer_list< type_t > items) noexcept |
| | Creates an xtd::span with specified initializer list.
|
| template<typename collection_t> |
| constexpr | span (collection_t &items, size_type length) |
| | Creates an xtd::span with specified collection and count.
|
| template<typename collection_t> |
| constexpr | span (collection_t &items, size_type start, size_type length) |
| | Creates an xtd::span with specified collection, offest and count.
|
| constexpr | span (type_t *const data, size_type length) |
| | Creates an xtd::span with specified data pointer and count.
|
|
| auto | begin () const -> const_iterator |
| | Returns an iterator to the beginning.
|
| auto | begin () -> iterator |
| | Returns an iterator to the beginning.
|
| auto | cbegin () const -> const_iterator |
| | Returns an iterator to the beginning.
|
| auto | cend () const -> const_iterator |
| | Returns an iterator to the end.
|
| constexpr auto | data () const noexcept -> const_pointer |
| | Gets direct access to the underlying contiguous storage.
|
| constexpr auto | empty () const noexcept -> bool |
| | Returns a value that indicates whether the current xtd::span <type_t> is empty.
|
| auto | end () const -> const_iterator |
| | Returns an iterator to the end.
|
| auto | end () -> iterator |
| | Returns an iterator to the end.
|
| constexpr auto | is_empty () const noexcept -> bool |
| | Returns a value that indicates whether the current xtd::span <type_t> is empty.
|
| constexpr auto | length () const noexcept -> size_type |
| | Returns the length of the current span.
|
| constexpr auto | size () const noexcept -> size_type |
| | Returns the number of elements.
|
| constexpr auto | size_bytes () const noexcept -> size_type |
| | Returns the size of the sequence in bytes.
|
|
| auto | clear () noexcept -> void |
| | Clears the contents of this xtd::span <type> object.
|
| template<xtd::usize length> |
| auto | copy_to (span< type_t, length > &destination) const -> void |
| | Copies the contents of this xtd::span <type_t> into a destination xtd:span <type_t>.
|
| auto | equals (const object &obj) const noexcept -> bool override |
| | Determines whether the specified object is equal to the current object.
|
| auto | equals (const span &rhs) const noexcept -> bool override |
| | Indicates whether the current object is equal to another object of the same type.
|
| auto | fill (const type_t &value) -> void |
| | Fills the elements of this span with a specified value.
|
| template<xtd::usize count> |
| auto | first () const -> span< type_t, count > |
| | Obtains a subspan consisting of the first count elements of the sequence.
|
| auto | first (xtd::usize count) const -> span< type_t > |
| | Obtains a subspan consisting of the first count elements of the sequence.
|
| auto | get_hash_code () const noexcept -> xtd::usize override |
| | Serves as a hash function for a particular type.
|
| template<xtd::usize count> |
| auto | last () const -> span< type_t, count > |
| | Obtains a subspan consisting of the last N elements of the sequence.
|
| auto | last (xtd::usize count) const -> span< type_t > |
| | Obtains a subspan consisting of the last N elements of the sequence.
|
| template<xtd::usize start, size_type lenght = xtd::dynamic_extent> |
| auto | slice () const -> span< type_t > |
| | Forms a slice out of the current span starting at a specified index for a specified length.
|
| auto | slice (size_type start) const -> span< type_t > |
| | Forms a slice out of the current span that begins at a specified index.
|
| auto | slice (size_type start, size_type length) const -> span< type_t > |
| | Forms a slice out of the current span starting at a specified index for a specified length.
|
| template<xtd::usize offset, size_type count = xtd::dynamic_extent> |
| auto | subspan () const -> span< type_t > |
| | Forms a subspan of the current span starting at a specified index for a specified length.
|
| auto | subspan (size_type offset, size_type count=xtd::dynamic_extent) const -> span< type_t > |
| | Forms a subspan of the current span starting at a specified index for a specified length.
|
| auto | to_array () const noexcept -> xtd::array< value_type > |
| | Copies the contents of this span into a new array.
|
| auto | to_string () const noexcept -> xtd::string override |
| | Returns the string representation of this xtd::span <type_t> object.
|
| template<xtd::usize length> |
| auto | try_copy_to (span< type_t, length > &destination) const noexcept -> bool |
| | Attempts to copy the current xtd::span <type_t> to a destination xtd::span <type_t> and returns a value that indicates whether the copy operation succeeded.
|
|
| | object ()=default |
| | Create a new instance of the ultimate base class object.
|
| virtual auto | get_type () const noexcept -> type_object |
| | Gets the type of the current instance.
|
| template<typename object_t> |
| auto | memberwise_clone () const -> xtd::unique_ptr_object< object_t > |
| | Creates a shallow copy of the current object.
|
| virtual auto | equals (const type_t &) const noexcept -> bool=0 |
| | Indicates whether the current object is equal to another object of the same type.
|
| template<typename object_a_t, typename object_b_t> |
| static auto | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool |
| | Determines whether the specified object instances are considered equal.
|
| template<typename object_a_t, typename object_b_t> |
| static auto | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool |
| | Determines whether the specified object instances are the same instance.
|