#include #include #include #include #include #include std::string_view first_field(std::string_view text) { return text.substr(0, text.find(',')); } void increment(std::span values) { for (int& n : values) ++n; } int main() { std::string text = "alpha,beta"; std::string_view field = first_field(text); assert(field == "alpha" && field.size() == 5); std::array values{1, 2, 3}; increment(std::span(values).subspan(1)); std::span read_only(values); assert(read_only[0] == 1 && read_only[1] == 3 && read_only[2] == 4); std::cout << field << ' ' << read_only[1] << ' ' << read_only[2] << '\n'; }