Header Reference: <span>
Header Reference: <span>
The non-owning contiguous view type std::span and the lifetime rules that matter when using it.
Header Reference: <span>
The non-owning contiguous view type std::span and the lifetime rules that matter when using it.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
Header reference pages are meant to answer a practical question quickly: what this header provides, when to reach for it, and which usage rules are easiest to get wrong.
<span>std::span<T, Extent>front, back, data, size, and subspanfirst, last, and subspanstd::span does not own the underlying dataT, so span<const T> is often the right read-only parameter type#include <span>
#include <array>
int sum(std::span<const int> values) {
int total = 0;
for (int value : values) {
total += value;
}
return total;
}