W3cubDocs

/C++

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

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()).

Parameters

idx - the index of the element to access

Return value

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

Exceptions

(none).

Notes

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

See also

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

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/container/span/operator_at