//******************************************************** // 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 #include #include int main() { std::vector coll{"Rome", "Berlin", "Kiev", "LA", "Tokyo", "Cairo"}; std::println("coll: {}", coll); auto gt2 = [] (auto s) { return s.size() > 2; }; auto tolower = [] (std::string s) { s[0] = static_cast(std::tolower(s[0])); return s; }; auto v = coll | std::views::filter(gt2) // significant size | std::ranges::to() // sorted | std::views::transform(tolower) // with lowered first character ; std::println("v: {}", v); }