xtd 0.2.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 "argument_null_exception.hpp"
#include "argument_out_of_range_exception.hpp"
#include "array.hpp"
#include "dynamic_extent.hpp"
#include "iequatable.hpp"
#include "index_out_of_range_exception.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<class type_t, xtd::size 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<class type_t, xtd::size extent = 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::size).
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.

Native types

using xtd::size
 Represents a size of any object in bytes.

Public Properties

static const read_only_span xtd::empty_read_only_span
 Returns an empty xtd::read_only_span <type_t> object.
const_reference xtd::back () const
 Gets the last element.
const_iterator xtd::begin () const
 Returns an iterator to the beginning.
const_iterator xtd::cbegin () const
 Returns an iterator to the beginning.
const_iterator xtd::cend () const
 Returns an iterator to the end.
const_reverse_iterator xtd::crbegin () const
 Returns a reverse iterator to the beginning.
const_reverse_iterator xtd::crend () const
 Returns a reverse iterator to the end.
constexpr const_pointer xtd::data () const noexcept
 Gets direct access to the underlying contiguous storage.
constexpr bool xtd::empty () const noexcept
 Returns a value that indicates whether the current xtd::read_only_span <type_t> is empty.
const_iterator xtd::end () const
 Returns an iterator to the end.
const_reference xtd::front () const
 Gets the first element.
constexpr bool xtd::is_empty () const noexcept
 Returns a value that indicates whether the current xtd::read_only_span <type_t> is empty.
constexpr size_type xtd::length () const noexcept
 Returns the length of the current read_only_span.
const_reverse_iterator xtd::rbegin () const
 Returns a reverse iterator to the beginning.
const_reverse_iterator xtd::rend () const
 Returns a reverse iterator to the end.
constexpr size_type xtd::size_bytes () const noexcept
 Returns the size of the sequence in bytes.

Public Constructors

template<xtd::size 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<class iterator_t>
constexpr xtd::read_only_span (iterator_t first, iterator_t last)
 Creates an xtd::read_only_span with specified iterators.
template<xtd::size len>
constexpr xtd::read_only_span (const element_type(&array)[len]) noexcept
 Creates an xtd::read_only_span with specified native array.
template<class array_type_t, xtd::size 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<class 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<class 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<class 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 Methods

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

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