[#absl-Span] = xref:absl.adoc[absl]::Span :relfileprefix: ../ :mrdocs: A non‐owning view over a contiguous sequence of objects. == Synopsis Declared in `<absl/types/span.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<typename T> class Span; ---- == Description A `Span` provides a bounds‐checked, `std::vector`‐like interface over an array whose storage is owned elsewhere. It can be constructed from a pointer and length, a C array, or any contiguous container, and it must not outlive the data it refers to. == Type Aliases [cols="1,4"] |=== | Name| Description | xref:absl/Span/absl_internal_is_view.adoc[`absl_internal_is_view`] | Tag marking `Span` as a view type. | xref:absl/Span/const_iterator.adoc[`const_iterator`] | A random‐access iterator over const elements. | xref:absl/Span/const_pointer.adoc[`const_pointer`] | A pointer to a const element. | xref:absl/Span/const_reference.adoc[`const_reference`] | A reference to a const element. | xref:absl/Span/const_reverse_iterator.adoc[`const_reverse_iterator`] | A reverse iterator over const elements. | xref:absl/Span/difference_type.adoc[`difference_type`] | A signed type used for iterator differences. | xref:absl/Span/element_type.adoc[`element_type`] | The element type, including any cv‐qualification. | xref:absl/Span/iterator.adoc[`iterator`] | A random‐access iterator over the elements. | xref:absl/Span/pointer.adoc[`pointer`] | A pointer to an element. | xref:absl/Span/reference.adoc[`reference`] | A reference to an element. | xref:absl/Span/reverse_iterator.adoc[`reverse_iterator`] | A reverse iterator over the elements. | xref:absl/Span/size_type.adoc[`size_type`] | An unsigned type used for sizes and indices. | xref:absl/Span/value_type.adoc[`value_type`] | The element type with cv‐qualifiers removed. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:absl/Span/2constructor-0a1.adoc[`Span`] [.small]#[constructor]# | Constructors | xref:absl/Span/at.adoc[`at`] | Returns a reference to the `i`th element, with bounds checking. | xref:absl/Span/back.adoc[`back`] | Returns a reference to the last element; the span must not be empty. | xref:absl/Span/begin.adoc[`begin`] | Returns an iterator to the first element. | xref:absl/Span/cbegin.adoc[`cbegin`] | Returns a const iterator to the first element. | xref:absl/Span/cend.adoc[`cend`] | Returns a const iterator just past the last element. | xref:absl/Span/crbegin.adoc[`crbegin`] | Returns a const reverse iterator to the last element. | xref:absl/Span/crend.adoc[`crend`] | Returns a const reverse iterator just before the first element. | xref:absl/Span/data.adoc[`data`] | Returns a pointer to the span's underlying array of data. | xref:absl/Span/empty.adoc[`empty`] | Reports whether this span is empty. | xref:absl/Span/end.adoc[`end`] | Returns an iterator just past the last element. | xref:absl/Span/first.adoc[`first`] | Returns a span containing the first `len` elements. | xref:absl/Span/front.adoc[`front`] | Returns a reference to the first element; the span must not be empty. | xref:absl/Span/last.adoc[`last`] | Returns a span containing the last `len` elements. | xref:absl/Span/length.adoc[`length`] | Returns the length (size) of this span. | xref:absl/Span/operator_subs.adoc[`operator[]`] | Returns a reference to the `i`th element of this span. | xref:absl/Span/rbegin.adoc[`rbegin`] | Returns a reverse iterator to the last element. | xref:absl/Span/remove_prefix.adoc[`remove_prefix`] | Removes the first `n` elements from the span. | xref:absl/Span/remove_suffix.adoc[`remove_suffix`] | Removes the last `n` elements from the span. | xref:absl/Span/rend.adoc[`rend`] | Returns a reverse iterator just before the first element. | xref:absl/Span/size.adoc[`size`] | Returns the number of elements in this span. | xref:absl/Span/subspan.adoc[`subspan`] | Returns a subspan starting at `pos` and spanning `len` elements. |=== == Static Data Members [cols="1,4"] |=== | Name| Description | xref:absl/Span/npos.adoc[`npos`] | Sentinel size value meaning "until the end of the span". |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:absl/AbslHashValue-03.adoc[absl::AbslHashValue]` | Hashes the span's elements for use with `absl::Hash`. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:absl/MakeConstSpan-05.adoc[`MakeConstSpan`] | Constructs a `Span<const T>` from a pointer and a size. | xref:absl/MakeConstSpan-06.adoc[`MakeConstSpan`] | Constructs a `Span<const T>` from a C array. | xref:absl/MakeConstSpan-07.adoc[`MakeConstSpan`] | Constructs a `Span<const T>` from a `[begin, end)]` pointer pair. | xref:absl/MakeSpan-0e2.adoc[`MakeSpan`] | Constructs a mutable `Span<T>` from a C array. | xref:absl/MakeSpan-0e4.adoc[`MakeSpan`] | Constructs a mutable `Span<T>` from a pointer and a size. | xref:absl/MakeSpan-0f.adoc[`MakeSpan`] | Constructs a mutable `Span<T>` from a `[begin, end)]` pointer pair. | xref:absl/operator_not_eq-0624.adoc[`operator!=`] | Compares two spans for inequality. | xref:absl/operator_not_eq-077.adoc[`operator!=`] | Compares a span to a container for inequality. | xref:absl/operator_not_eq-0a.adoc[`operator!=`] | Compares two spans for inequality. | xref:absl/operator_not_eq-0e4.adoc[`operator!=`] | Compares two spans for inequality. | xref:absl/operator_lt-04c.adoc[`operator<`] | Compares two spans lexicographically. | xref:absl/operator_lt-06d.adoc[`operator<`] | Compares two spans lexicographically. | xref:absl/operator_lt-08.adoc[`operator<`] | Compares two spans lexicographically. | xref:absl/operator_lt-0ed.adoc[`operator<`] | Compares a span and a container lexicographically. | xref:absl/operator_le-003.adoc[`operator<=`] | Compares two spans lexicographically. | xref:absl/operator_le-0bf.adoc[`operator<=`] | Compares two spans lexicographically. | xref:absl/operator_le-0d.adoc[`operator<=`] | Compares two spans lexicographically. | xref:absl/operator_le-0e.adoc[`operator<=`] | Compares a span and a container lexicographically. | xref:absl/operator_eq-02b.adoc[`operator==`] | Compares two spans for element‐wise equality. | xref:absl/operator_eq-084.adoc[`operator==`] | Compares two spans for element‐wise equality. | xref:absl/operator_eq-0c1.adoc[`operator==`] | Compares a span to a container for element‐wise equality. | xref:absl/operator_eq-0d6.adoc[`operator==`] | Compares two spans for element‐wise equality. | xref:absl/operator_gt-085.adoc[`operator>`] | Compares two spans lexicographically. | xref:absl/operator_gt-08f.adoc[`operator>`] | Compares two spans lexicographically. | xref:absl/operator_gt-091.adoc[`operator>`] | Compares two spans lexicographically. | xref:absl/operator_gt-0c7.adoc[`operator>`] | Compares a span and a container lexicographically. | xref:absl/operator_ge-03e0.adoc[`operator>=`] | Compares two spans lexicographically. | xref:absl/operator_ge-03ec.adoc[`operator>=`] | Compares two spans lexicographically. | xref:absl/operator_ge-04e.adoc[`operator>=`] | Compares two spans lexicographically. | xref:absl/operator_ge-06.adoc[`operator>=`] | Compares a span and a container lexicographically. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#