Understand const semantics with std::span
std::span has different const behavior than containers: const applies to the span object, not necessarily the elements.
The key difference
Section titled “The key difference”const std::span<int> span1; // const container, mutable elementsstd::span<const int> span2; // mutable container, const elementsconst std::span<const int> span3; // both constCompare with:
const std::vector<int> vec; // Both container and elements are constFor function parameters
Section titled “For function parameters”// Elements are const, span itself can be reassignedvoid read_only(std::span<const int> data);
// Both span and elements are constvoid truly_const(const std::span<const int> data);