// Stage 03: vector owns values; span borrows a contiguous range and length.
#include <iostream>
#include <span>
#include <vector>
int total_of(std::span<const int> readings) {
    int total=0;
    for(const int value:readings) total+=value;
    return total; // The small teaching inputs keep the sum within int.
}
int main() {
    const std::vector<int> readings{3,1,4,1,5};
    const std::span<const int> view{readings};
    auto independent=readings; // Own a copy of all five values.
    independent[0]+=10;
    if(total_of(view)!=14 || total_of(independent)!=24) return 1;
    if(total_of(std::span<const int>{})!=0) return 2;
    const std::vector<int> single{5};
    if(total_of(single)!=5) return 3;
    // The owner is still alive; no operation reallocates its storage.
    std::cout<<"owner="<<total_of(readings)<<" copy="<<total_of(independent)
             <<" borrowed="<<total_of(view)<<'\n';
}
