xtd 0.2.0
xtd::read_only_span< type_t, extent > Class Template Reference
Inheritance diagram for xtd::read_only_span< type_t, extent >:
xtd::object xtd::iequatable< type_t > xtd::interface xtd::extensions::equality_operators< type_t, iequatable< type_t > >

Definition

template<class type_t, xtd::size extent = dynamic_extent>
class xtd::read_only_span< type_t, extent >

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:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
Represents a non-owning view over a contiguous sequence of objects.
Definition read_only_span.hpp:52
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};
Represents a non-owning view over a contiguous sequence of objects.
Definition span.hpp:58

Public Aliases

using element_type = std::add_cv_t< type_t >
 Represents the read_only_span elemeent type.
 
using value_type = std::add_cv_t< type_t >
 Represents the read_only_span value type.
 
using size_type = xtd::size
 Represents the read_only_span size type (usually xtd::size).
 
using difference_type = xtd::ptrdiff
 Represents the read_only_span difference type (usually xtd::ptrdiff).
 
using pointer = const type_t *
 Represents the read_only_span pointer type.
 
using const_pointer = const type_t *
 Represents the read_only_span const pointer type.
 
using reference = const type_t &
 Represents the read_only_span reference type.
 
using const_reference = const type_t &
 Represents the read_only_span const reference type.
 
using iterator = const xtd::collections::generic::helpers::wrap_pointer_iterator< pointer >
 Represents the iterator of read_only_span value type.
 
using const_iterator = const xtd::collections::generic::helpers::wrap_pointer_iterator< pointer >
 Represents the const iterator of read_only_span value type.
 
using reverse_iterator = const std::reverse_iterator< xtd::collections::generic::helpers::wrap_pointer_iterator< pointer > >
 Represents the reverse iterator of read_only_span value type.
 
using const_reverse_iterator = const std::reverse_iterator< xtd::collections::generic::helpers::wrap_pointer_iterator< pointer > >
 Represents the const reverse iterator of read_only_span value type.
 

Public Properties

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

Public Constructors

template<xtd::size count = 0>
constexpr 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 read_only_span (iterator_t first, iterator_t last)
 Creates an xtd::read_only_span with specified iterators.
 
template<xtd::size len>
constexpr 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 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 read_only_span (range_t &&range) noexcept
 Creates an xtd::read_only_span with specified range.
 
constexpr 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 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 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 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 at (size_type pos) const
 Gets the specified element with bounds checking.
 
template<xtd::size length>
void 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 equals (const object &obj) const noexcept override
 Determines whether the specified object is equal to the current object.
 
bool 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 > first () const
 Obtains a subspan consisting of the first count elements of the sequence.
 
read_only_span< type_t > first (xtd::size count) const
 Obtains a subspan consisting of the first count elements of the sequence.
 
xtd::size 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 > last () const
 Obtains a subspan consisting of the last N elements of the sequence.
 
read_only_span< type_t > 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 > 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 > 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 > 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 > 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 > 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 > > to_array () const noexcept
 Copies the contents of this read_only_span into a new array.
 
string to_string () const noexcept override
 Returns the string representation of this xtd::read_only_span <type_t> object.
 
template<xtd::size length>
bool 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 operator[] (size_type index) const
 Gets the element at the specified zero-based index.
 

Additional Inherited Members

- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<class object_t >
xtd::uptr< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
- Public Member Functions inherited from xtd::iequatable< type_t >
virtual bool equals (const type_t &) const noexcept=0
 Indicates whether the current object is equal to another object of the same type.
 
- Static Public Member Functions inherited from xtd::object
template<class object_a_t , class object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<class object_a_t , class object_b_t >
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Member Typedef Documentation

◆ element_type

template<class type_t , xtd::size extent = dynamic_extent>
using xtd::read_only_span< type_t, extent >::element_type = std::add_cv_t<type_t>

Represents the read_only_span elemeent type.

◆ value_type

template<class type_t , xtd::size extent = dynamic_extent>
using xtd::read_only_span< type_t, extent >::value_type = std::add_cv_t<type_t>

Represents the read_only_span value type.

◆ size_type

template<class type_t , xtd::size extent = dynamic_extent>
using xtd::read_only_span< type_t, extent >::size_type = xtd::size

Represents the read_only_span size type (usually xtd::size).

◆ difference_type

template<class type_t , xtd::size extent = dynamic_extent>
using xtd::read_only_span< type_t, extent >::difference_type = xtd::ptrdiff

Represents the read_only_span difference type (usually xtd::ptrdiff).

◆ pointer

template<class type_t , xtd::size extent = dynamic_extent>
using xtd::read_only_span< type_t, extent >::pointer = const type_t*

Represents the read_only_span pointer type.

◆ const_pointer

template<class type_t , xtd::size extent = dynamic_extent>
using xtd::read_only_span< type_t, extent >::const_pointer = const type_t*

Represents the read_only_span const pointer type.

◆ reference

template<class type_t , xtd::size extent = dynamic_extent>
using xtd::read_only_span< type_t, extent >::reference = const type_t&

Represents the read_only_span reference type.

◆ const_reference

template<class type_t , xtd::size extent = dynamic_extent>
using xtd::read_only_span< type_t, extent >::const_reference = const type_t&

Represents the read_only_span const reference type.

◆ iterator

template<class type_t , xtd::size extent = dynamic_extent>
using xtd::read_only_span< type_t, extent >::iterator = const xtd::collections::generic::helpers::wrap_pointer_iterator<pointer>

Represents the iterator of read_only_span value type.

◆ const_iterator

template<class type_t , xtd::size extent = dynamic_extent>
using xtd::read_only_span< type_t, extent >::const_iterator = const xtd::collections::generic::helpers::wrap_pointer_iterator<pointer>

Represents the const iterator of read_only_span value type.

◆ reverse_iterator

template<class type_t , xtd::size extent = dynamic_extent>
using xtd::read_only_span< type_t, extent >::reverse_iterator = const std::reverse_iterator<xtd::collections::generic::helpers::wrap_pointer_iterator<pointer> >

Represents the reverse iterator of read_only_span value type.

◆ const_reverse_iterator

template<class type_t , xtd::size extent = dynamic_extent>
using xtd::read_only_span< type_t, extent >::const_reverse_iterator = const std::reverse_iterator<xtd::collections::generic::helpers::wrap_pointer_iterator<pointer> >

Represents the const reverse iterator of read_only_span value type.

Constructor & Destructor Documentation

◆ read_only_span() [1/9]

template<class type_t , xtd::size extent = dynamic_extent>
template<xtd::size count = 0>
constexpr xtd::read_only_span< type_t, extent >::read_only_span ( )
inlineconstexpr

◆ read_only_span() [2/9]

template<class type_t , xtd::size extent = dynamic_extent>
template<class iterator_t >
constexpr xtd::read_only_span< type_t, extent >::read_only_span ( iterator_t  first,
iterator_t  last 
)
inlineconstexpr

Creates an xtd::read_only_span with specified iterators.

Parameters
firstThe iterator to the first element of the sequence.
lastThe iterator to the last element of the sequence.

◆ read_only_span() [3/9]

template<class type_t , xtd::size extent = dynamic_extent>
template<xtd::size len>
constexpr xtd::read_only_span< type_t, extent >::read_only_span ( const element_type(&)  array[len])
inlineconstexprnoexcept

Creates an xtd::read_only_span with specified native array.

Parameters
arrayThe native array to construct a view for.

◆ read_only_span() [4/9]

template<class type_t , xtd::size extent = dynamic_extent>
template<class array_type_t , xtd::size len>
constexpr xtd::read_only_span< type_t, extent >::read_only_span ( const std::array< array_type_t, len > &  array)
inlineconstexprnoexcept

Creates an xtd::read_only_span with specified std::array.

Parameters
arrayThe std::array to construct a view for.

◆ read_only_span() [5/9]

template<class type_t , xtd::size extent = dynamic_extent>
template<class range_t >
constexpr xtd::read_only_span< type_t, extent >::read_only_span ( range_t &&  range)
inlineconstexprnoexcept

Creates an xtd::read_only_span with specified range.

Parameters
rangeThe range to construct a view for.

◆ read_only_span() [6/9]

template<class type_t , xtd::size extent = dynamic_extent>
constexpr xtd::read_only_span< type_t, extent >::read_only_span ( std::initializer_list< type_t >  items)
inlineconstexprnoexcept

Creates an xtd::read_only_span with specified initializer list.

Parameters
itemsThe initializer list to construct a view for.

◆ read_only_span() [7/9]

template<class type_t , xtd::size extent = dynamic_extent>
template<class collection_t >
constexpr xtd::read_only_span< type_t, extent >::read_only_span ( const collection_t &  items,
size_type  length 
)
inlineconstexpr

Creates an xtd::read_only_span with specified collection and count.

Parameters
itemsThe collection to construct a view for.
lengthThe number of elements in the collection.
Exceptions
xtd::argument_out_of_range_exceptionif length is greater than items size.

◆ read_only_span() [8/9]

template<class type_t , xtd::size extent = dynamic_extent>
template<class collection_t >
constexpr xtd::read_only_span< type_t, extent >::read_only_span ( const collection_t &  items,
size_type  start,
size_type  length 
)
inlineconstexpr

Creates an xtd::read_only_span with specified collection, offest and count.

Parameters
itemsThe collection to construct a view for.
startThe offset in the collection.
lengthThe number of elements in the collection.
Exceptions
xtd::argument_out_of_range_exceptionif offset or offset + length are greater than items size.

◆ read_only_span() [9/9]

template<class type_t , xtd::size extent = dynamic_extent>
constexpr xtd::read_only_span< type_t, extent >::read_only_span ( const type_t *  data,
size_type  length 
)
inlineconstexpr

Creates an xtd::read_only_span with specified data pointer and count.

Parameters
dataThe data pointer to construct a view for.
lengthThe number of elements to constuct.

Member Function Documentation

◆ back()

template<class type_t , xtd::size extent = dynamic_extent>
const_reference xtd::read_only_span< type_t, extent >::back ( ) const
inline

Gets the last element.

Returns
The last element.
Exceptions
argument_out_of_range_exceptionif xtd::san i empty.

◆ begin()

template<class type_t , xtd::size extent = dynamic_extent>
const_iterator xtd::read_only_span< type_t, extent >::begin ( ) const
inline

Returns an iterator to the beginning.

Returns
The iterator of the first element.

◆ cbegin()

template<class type_t , xtd::size extent = dynamic_extent>
const_iterator xtd::read_only_span< type_t, extent >::cbegin ( ) const
inline

Returns an iterator to the beginning.

Returns
The iterator of the first element.

◆ cend()

template<class type_t , xtd::size extent = dynamic_extent>
const_iterator xtd::read_only_span< type_t, extent >::cend ( ) const
inline

Returns an iterator to the end.

Returns
The iterator to the element following the last element.

◆ crbegin()

template<class type_t , xtd::size extent = dynamic_extent>
const_reverse_iterator xtd::read_only_span< type_t, extent >::crbegin ( ) const
inline

Returns a reverse iterator to the beginning.

Returns
The reverse iterator of the first element.

◆ crend()

template<class type_t , xtd::size extent = dynamic_extent>
const_reverse_iterator xtd::read_only_span< type_t, extent >::crend ( ) const
inline

Returns a reverse iterator to the end.

Returns
The reverse iterator to the element following the last element.

◆ data()

template<class type_t , xtd::size extent = dynamic_extent>
constexpr const_pointer xtd::read_only_span< type_t, extent >::data ( ) const
inlineconstexprnoexcept

Gets direct access to the underlying contiguous storage.

Returns
A pointer to the beginning of the sequence.

◆ empty()

template<class type_t , xtd::size extent = dynamic_extent>
constexpr bool xtd::read_only_span< type_t, extent >::empty ( ) const
inlineconstexprnoexcept

Returns a value that indicates whether the current xtd::read_only_span <type_t> is empty.

Returns
true if the current read_only_span is empty; otherwise, false.

◆ end()

template<class type_t , xtd::size extent = dynamic_extent>
const_iterator xtd::read_only_span< type_t, extent >::end ( ) const
inline

Returns an iterator to the end.

Returns
The iterator to the element following the last element.

◆ front()

template<class type_t , xtd::size extent = dynamic_extent>
const_reference xtd::read_only_span< type_t, extent >::front ( ) const
inline

Gets the first element.

Returns
The first element.
Exceptions
argument_out_of_range_exceptionif xtd::san i empty.

◆ is_empty()

template<class type_t , xtd::size extent = dynamic_extent>
constexpr bool xtd::read_only_span< type_t, extent >::is_empty ( ) const
inlineconstexprnoexcept

Returns a value that indicates whether the current xtd::read_only_span <type_t> is empty.

Returns
true if the current read_only_span is empty; otherwise, false.

◆ length()

template<class type_t , xtd::size extent = dynamic_extent>
constexpr size_type xtd::read_only_span< type_t, extent >::length ( ) const
inlineconstexprnoexcept

Returns the length of the current read_only_span.

Returns
The length of the current read_only_span.

◆ rbegin()

template<class type_t , xtd::size extent = dynamic_extent>
const_reverse_iterator xtd::read_only_span< type_t, extent >::rbegin ( ) const
inline

Returns a reverse iterator to the beginning.

Returns
The reverse iterator of the first element.

◆ rend()

template<class type_t , xtd::size extent = dynamic_extent>
const_reverse_iterator xtd::read_only_span< type_t, extent >::rend ( ) const
inline

Returns a reverse iterator to the end.

Returns
The reverse iterator to the element following the last element.

◆ size()

template<class type_t , xtd::size extent = dynamic_extent>
constexpr size_type xtd::read_only_span< type_t, extent >::size ( ) const
inlineconstexprnoexcept

Returns the number of elements.

Returns
The number of elements in the read_only_span.

◆ size_bytes()

template<class type_t , xtd::size extent = dynamic_extent>
constexpr size_type xtd::read_only_span< type_t, extent >::size_bytes ( ) const
inlineconstexprnoexcept

Returns the size of the sequence in bytes.

Returns
The size of the sequence in bytes, i.e., size() * sizeof(element_type).

◆ at()

template<class type_t , xtd::size extent = dynamic_extent>
const_reference xtd::read_only_span< type_t, extent >::at ( size_type  pos) const
inline

Gets the specified element with bounds checking.

Parameters
posThe position of the element to return.
Returns
Reference to the requested element.
Exceptions
xtd::index_out_of_range_exception`index` is less than zero or greater than or equal to xtd::read_only_span::length.

◆ copy_to()

template<class type_t , xtd::size extent = dynamic_extent>
template<xtd::size length>
void xtd::read_only_span< type_t, extent >::copy_to ( span< type_t, length > &  destination) const
inline

Copies the contents of this xtd::read_only_span <type_t> into a destination xtd:span <type_t>.

Parameters
destinatonThe destination xtd::read_only_span <type_t> object.
Exceptions
xtd::argument_exception`destination` is shorter than the source xtd::span <type_t>.

◆ equals() [1/2]

template<class type_t , xtd::size extent = dynamic_extent>
bool xtd::read_only_span< type_t, extent >::equals ( const object obj) const
inlineoverridevirtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.

Reimplemented from xtd::object.

◆ equals() [2/2]

template<class type_t , xtd::size extent = dynamic_extent>
bool xtd::read_only_span< type_t, extent >::equals ( const read_only_span< type_t, extent > &  rhs) const
inlineoverridenoexcept

Indicates whether the current object is equal to another object of the same type.

Parameters
objAn object to compare with this object.
Returns
true if the current object is equal to the other parameter; otherwise, false.

◆ first() [1/2]

template<class type_t , xtd::size extent = dynamic_extent>
template<xtd::size count>
read_only_span< type_t, count > xtd::read_only_span< type_t, extent >::first ( ) const
inline

Obtains a subspan consisting of the first count elements of the sequence.

Parameters
countThe count elements.
Returns
A read_only_span r that is a view over the first count elements of *this, such that r.data() == this->data() && r.size() == count.

◆ first() [2/2]

template<class type_t , xtd::size extent = dynamic_extent>
read_only_span< type_t > xtd::read_only_span< type_t, extent >::first ( xtd::size  count) const
inline

Obtains a subspan consisting of the first count elements of the sequence.

Parameters
countThe count elements.
Returns
A read_only_span r that is a view over the first count elements of *this, such that r.data() == this->data() && r.size() == count.

◆ get_hash_code()

template<class type_t , xtd::size extent = dynamic_extent>
xtd::size xtd::read_only_span< type_t, extent >::get_hash_code ( ) const
inlineoverridevirtualnoexcept

Serves as a hash function for a particular type.

Returns
A hash code for the current object.

Reimplemented from xtd::object.

◆ last() [1/2]

template<class type_t , xtd::size extent = dynamic_extent>
template<xtd::size count>
read_only_span< type_t, count > xtd::read_only_span< type_t, extent >::last ( ) const
inline

Obtains a subspan consisting of the last N elements of the sequence.

Parameters
countThe count elements.
Returns
A read_only_span r that is a view over the last count elements of *this, such that r.data() == this->data() + (this->size() - count) && r.size() == count.

◆ last() [2/2]

template<class type_t , xtd::size extent = dynamic_extent>
read_only_span< type_t > xtd::read_only_span< type_t, extent >::last ( xtd::size  count) const
inline

Obtains a subspan consisting of the last N elements of the sequence.

Parameters
countThe count elements.
Returns
A read_only_span r that is a view over the last count elements of *this, such that r.data() == this->data() + (this->size() - count) && r.size() == count.

◆ slice() [1/3]

template<class type_t , xtd::size extent = dynamic_extent>
template<xtd::size start, size_type lenght = xtd::dynamic_extent>
read_only_span< type_t > xtd::read_only_span< type_t, extent >::slice ( ) const
inline

Forms a slice out of the current read_only_span starting at a specified index for a specified length.

Parameters
startThe zero-based index at which to begin this slice.
lengthThe desired length for the slice.
Returns
A read_only_span that consists of length elements from the current read_only_span starting at start.
Exceptions
xtd::argument_out_of_range_exception`start` or `start + length` is less than zero or greater than xtd::read_only_span::length.

◆ slice() [2/3]

template<class type_t , xtd::size extent = dynamic_extent>
read_only_span< type_t > xtd::read_only_span< type_t, extent >::slice ( size_type  start) const
inline

Forms a slice out of the current read_only_span that begins at a specified index.

Parameters
startThe zero-based index at which to begin the slice.
Returns
A read_only_span that consists of all elements of the current read_only_span from start to the end of the read_only_span.
Exceptions
xtd::argument_out_of_range_exception`start` is less than zero or greater than xtd::read_only_span::length.

◆ slice() [3/3]

template<class type_t , xtd::size extent = dynamic_extent>
read_only_span< type_t > xtd::read_only_span< type_t, extent >::slice ( size_type  start,
size_type  length 
) const
inline

Forms a slice out of the current read_only_span starting at a specified index for a specified length.

Parameters
startThe zero-based index at which to begin this slice.
lengthThe desired length for the slice.
Returns
A read_only_span that consists of length elements from the current read_only_span starting at start.
Exceptions
xtd::argument_out_of_range_exception`start` or `start + length` is less than zero or greater than xtd::read_only_span::length.

◆ subspan() [1/2]

template<class type_t , xtd::size extent = dynamic_extent>
template<xtd::size offset, size_type count = xtd::dynamic_extent>
read_only_span< type_t > xtd::read_only_span< type_t, extent >::subspan ( ) const
inline

Forms a subspan of the current read_only_span starting at a specified index for a specified length.

Parameters
offsetThe zero-based index at which to begin this slice.
countThe desired length for the slice.
Returns
A read_only_span that consists of length elements from the current read_only_span starting at start.
Exceptions
xtd::argument_out_of_range_exception`offset` or `offset + count` is less than zero or greater than xtd::read_only_span::length.

◆ subspan() [2/2]

template<class type_t , xtd::size extent = dynamic_extent>
read_only_span< type_t > xtd::read_only_span< type_t, extent >::subspan ( size_type  offset,
size_type  count = xtd::dynamic_extent 
) const
inline

Forms a subspan of the current read_only_span starting at a specified index for a specified length.

Parameters
offsetThe zero-based index at which to begin this slice.
countThe desired length for the slice.
Returns
A read_only_span that consists of length elements from the current read_only_span starting at start.
Exceptions
xtd::argument_out_of_range_exception`offset` or `offset + count` is less than zero or greater than xtd::read_only_span::length.

◆ to_array()

template<class type_t , xtd::size extent = dynamic_extent>
xtd::array< std::remove_cv_t< type_t > > xtd::read_only_span< type_t, extent >::to_array ( ) const
inlinenoexcept

Copies the contents of this read_only_span into a new array.

Returns
An array containing the data in the current read_only_span.

◆ to_string()

template<class type_t , xtd::size extent = dynamic_extent>
string xtd::read_only_span< type_t, extent >::to_string ( ) const
inlineoverridevirtualnoexcept

Returns the string representation of this xtd::read_only_span <type_t> object.

Returns
The string representation of this xtd::read_only_span <type_t> object.
Remarks
For a xtd::read_only_span <type_t>, the xtd::read_only_span::to_string method returns a xtd::string that contains the characters pointed to by the xtd::read_only_span <type_t>. Otherwise, it returns a xtd::string with collection sequance string of the elements that the xtd::read_only_span <type_t> contains separated by ,.

Reimplemented from xtd::object.

◆ try_copy_to()

template<class type_t , xtd::size extent = dynamic_extent>
template<xtd::size length>
bool xtd::read_only_span< type_t, extent >::try_copy_to ( span< type_t, length > &  destination) const
inlinenoexcept

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.

Parameters
destinationThe target of the copy operation.
Returns
true if the copy operation succeeded; otherwise, false.
Remarks
This method copies all of source to destination even if source and destination overlap.

◆ operator[]()

template<class type_t , xtd::size extent = dynamic_extent>
const_reference xtd::read_only_span< type_t, extent >::operator[] ( size_type  index) const
inline

Gets the element at the specified zero-based index.

Parameters
indexThe zero-based index of the element.
Returns
The element at the specified index.
Exceptions
xtd::index_out_of_range_exception`index` is less than zero or greater than or equal to xtd::read_only_span::length.

Member Data Documentation

◆ empty_read_only_span

template<class type_t , xtd::size extent>
const read_only_span< type_t, extent > xtd::read_only_span< type_t, extent >::empty_read_only_span
inlinestatic

Returns an empty xtd::read_only_span <type_t> object.

Returns
An empty xtd::read_only_span <type_t> object.

The documentation for this class was generated from the following file: