//******************************************************** // The following code example is taken from the book // C++23 - The Complete Guide // by Nicolai M. Josuttis (www.josuttis.com) // http://www.cppstd23.com // // The code is licensed under a // Creative Commons Attribution 4.0 International License // http://creativecommons.org/licenses/by/4.0/ //******************************************************** #include #include #include int main() { std::vector coll{1, 2, 3, 4, 1, 2, 3, 4}; std::println("coll: {}", v); // define and USE view: auto v = coll | std::views::split(1); std::println("split(3): {}\n", v); // modify underlying range: coll.erase(coll.begin()); // use view again: std::println("1st removed: {}", coll); std::println("split again: {}", v); }