//******************************************************** // 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 #include int main() { std::vector coll{"Rome", "Berlin", "LA", "Kiev", "NY"}; // copy to sub-sequences of three elements: auto vec1 = coll | std::views::adjacent<3> | std::ranges::to(); std::println("coll: {}", coll); std::println("vec1: {}\n", vec1); // move to sub-sequences of three elements: auto vec2 = coll | std::views::adjacent<3> | std::views::as_rvalue | std::ranges::to(); std::println("coll: {}", coll); std::println("vec2: {}", vec2); }