xtd 1.0.0
Loading...
Searching...
No Matches
read_only_span.hpp File Reference
#include "internal/__xtd_std_version.hpp"
#include "collections/generic/helpers/wrap_pointer_iterator.hpp"
#include "array.hpp"
#include "dynamic_extent.hpp"
#include "iequatable.hpp"
#include "is.hpp"
#include "null.hpp"
#include "object.hpp"
#include "ptrdiff.hpp"
#include "views/views.hpp"
#include "span.hpp"
#include "typeof.hpp"
#include <type_traits>
#include <vector>

Definition

Contains xtd::read_only_span class.

Go to the source code of this file.

Namespaces

namespace  xtd
 The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.

Public Aliases

Represents a non-owning view over a contiguous sequence of objects.

Definition
template<typename type_t, xtd::usize extent = dynamic_extent>
class read_only_span : public xtd::object, public xtd::iequatable<xtd::read_only_span<type_t, 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
Header
#include <xtd/read_only_span>
Namespace
xtd
Library
xtd.core
Remarks
The class template xtd::read_only_span describes an object that can refer to a contiguous sequence of objects with the first element of the sequence at position zero. A read_only_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.
The referenced data can't be modified through a xtd::read_only_span object. To prevent this, use a xtd::only_span`:
int numbers[] = {0, 1, 2};
read_only_span<int> read_only_span_numbers = numbers;
read_only_span_numbers[0] = 42; // ERROR: read_only_span_numbers[0] is read-only
span<int> span_numbers = numbers;
span_numbers[0] = 42; // numbers == {42, 1, 2};
template<typename type_t, xtd::usize extent = xtd::dynamic_extent> */ class read_only_span : public xtd::object, public xtd::iequatable<xtd::read_only_span<type_t, extent>> { public: /

/**

Represents the read_only_span elemeent type.

using xtd::element_type
using xtd::value_type
 Represents the read_only_span value type.
using xtd::size_type
 Represents the read_only_span size type (usually xtd::usize).
using xtd::difference_type
 Represents the read_only_span difference type (usually xtd::ptrdiff).
using xtd::pointer
 Represents the read_only_span pointer type.
using xtd::const_pointer
 Represents the read_only_span const pointer type.
using xtd::reference
 Represents the read_only_span reference type.
using xtd::const_reference
 Represents the read_only_span const reference type.
using xtd::iterator
 Represents the iterator of read_only_span value type.
using xtd::const_iterator
 Represents the const iterator of read_only_span value type.
using xtd::reverse_iterator
 Represents the reverse iterator of read_only_span value type.
using xtd::const_reverse_iterator
 Represents the const reverse iterator of read_only_span value type.

Public Fields

static const read_only_span xtd::empty_read_only_span
 Returns an empty xtd::read_only_span <type_t> object.

Public Constructors

template<xtd::usize count = 0>
constexpr xtd::read_only_span ()
 Creates an empty xtd::read_only_span whose xtd::read_only_span::data is null and xtd::read_only_span::size is 0.
template<typename iterator_t>
constexpr xtd::read_only_span (iterator_t first, iterator_t last)
 Creates an xtd::read_only_span with specified iterators.
template<xtd::usize len>
constexpr xtd::read_only_span (const element_type(&array)[len]) noexcept
 Creates an xtd::read_only_span with specified native array.
template<typename array_type_t, xtd::usize len>
constexpr xtd::read_only_span (const std::array< array_type_t, len > &array) noexcept
 Creates an xtd::read_only_span with specified std::array.
template<typename array_type_t>
constexpr xtd::read_only_span (const xtd::array< array_type_t > &items)
 Creates an xtd::span with specified collection and count.
template<typename range_t>
constexpr xtd::read_only_span (range_t &&range) noexcept
 Creates an xtd::read_only_span with specified range.
constexpr xtd::read_only_span (std::initializer_list< type_t > items) noexcept
 Creates an xtd::read_only_span with specified initializer list.
template<typename collection_t>
constexpr xtd::read_only_span (const collection_t &items, size_type length)
 Creates an xtd::read_only_span with specified collection and count.
template<typename collection_t>
constexpr xtd::read_only_span (const collection_t &items, size_type start, size_type length)
 Creates an xtd::read_only_span with specified collection, offest and count.
constexpr xtd::read_only_span (const type_t *data, size_type length)
 Creates an xtd::read_only_span with specified data pointer and count.

Public Properties

@

auto xtd::begin () const -> const_iterator
 Returns an iterator to the beginning.
auto xtd::cbegin () const -> const_iterator
 Returns an iterator to the beginning.
auto xtd::cend () const -> const_iterator
 Returns an iterator to the end.
constexpr auto xtd::data () const noexcept -> const_pointer
 Gets direct access to the underlying contiguous storage.
constexpr auto xtd::empty () const noexcept -> bool
 Returns a value that indicates whether the current xtd::read_only_span <type_t> is empty.
auto xtd::end () const -> const_iterator
 Returns an iterator to the end.
constexpr auto xtd::is_empty () const noexcept -> bool
 Returns a value that indicates whether the current xtd::read_only_span <type_t> is empty.
constexpr auto xtd::length () const noexcept -> size_type
 Returns the length of the current read_only_span.
constexpr auto xtd::size () const noexcept -> size_type
 Returns the number of elements.
constexpr auto xtd::size_bytes () const noexcept -> size_type
 Returns the size of the sequence in bytes.

Public Methods

template<xtd::usize length>
auto xtd::copy_to (span< type_t, length > &destination) const -> void
 Copies the contents of this xtd::read_only_span <type_t> into a destination xtd:span <type_t>.
auto xtd::equals (const object &obj) const noexcept -> bool override
 Determines whether the specified object is equal to the current object.
auto xtd::equals (const read_only_span &rhs) const noexcept -> bool override
 Indicates whether the current object is equal to another object of the same type.
template<xtd::usize count>
auto xtd::first () const -> read_only_span< type_t, count >
 Obtains a subspan consisting of the first count elements of the sequence.
auto xtd::first (xtd::usize count) const -> read_only_span< type_t >
 Obtains a subspan consisting of the first count elements of the sequence.
auto xtd::get_hash_code () const noexcept -> xtd::usize override
 Serves as a hash function for a particular type.
template<xtd::usize count>
auto xtd::last () const -> read_only_span< type_t, count >
 Obtains a subspan consisting of the last N elements of the sequence.
auto xtd::last (xtd::usize count) const -> read_only_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 xtd::slice () const -> read_only_span< type_t >
 Forms a slice out of the current read_only_span starting at a specified index for a specified length.
auto xtd::slice (size_type start) const -> read_only_span< type_t >
 Forms a slice out of the current read_only_span that begins at a specified index.
auto xtd::slice (size_type start, size_type length) const -> read_only_span< type_t >
 Forms a slice out of the current read_only_span starting at a specified index for a specified length.
template<xtd::usize offset, size_type count = xtd::dynamic_extent>
auto xtd::subspan () const -> read_only_span< type_t >
 Forms a subspan of the current read_only_span starting at a specified index for a specified length.
auto xtd::subspan (size_type offset, size_type count=xtd::dynamic_extent) const -> read_only_span< type_t >
 Forms a subspan of the current read_only_span starting at a specified index for a specified length.
auto xtd::to_array () const noexcept -> xtd::array< std::remove_cv_t< type_t > >
 Copies the contents of this read_only_span into a new array.
auto xtd::to_string () const noexcept -> xtd::string override
 Returns the string representation of this xtd::read_only_span <type_t> object.
template<xtd::usize length>
auto xtd::try_copy_to (span< type_t, length > &destination) const noexcept -> bool
 Attempts to copy the current xtd::read_only_span <type_t> to a destination xtd::read_only_span <type_t> and returns a value that indicates whether the copy operation succeeded.

Public Operators

auto xtd::operator[] (size_type index) const -> const_reference
 Gets the element at the specified zero-based index.