Namespaces
Variants
Views
Actions

std::span::operator[], std::span::operator()

From cppreference.com
< cpp‎ | container‎ | span
constexpr reference operator[](index_type idx) const;
constexpr reference operator()(index_type idx) const;

Returns a reference to the idx-th element of the sequence. The behavior is undefined if idx is out of range (i.e., if it is less than zero or greater than or equal to size()).

Contents

[edit] Parameters

idx - the index of the element to access

[edit] Return value

A reference to the idx-th element of the sequence, i.e., data()[idx]

[edit] Exceptions

(none)

[edit] Notes

operator() is overloaded for consistency with proposed multidimensional arrays, which are indexed as array3D(i, j, k)

[edit] See also

returns a pointer to the beginning of the sequence of elements
(public member function) [edit]
returns the number of elements in the sequence
(public member function) [edit]