//******************************************************** // 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 int main() { std::list> pairs{{7, "Rio"}, {1, "LA"}, {2,"NY"}}; std::map map1{std::from_range, pairs}; std::println("map1: {}", map1); std::map map2{std::from_range, pairs}; std::println("map2: {}", map2); std::vector vec{"tic", "tac", "toe"}; std::map map3{std::from_range, vec | std::views::enumerate}; std::println("map3: {}", map3); std::map map4{std::from_range, std::views::enumerate(vec)}; std::println("map4: {}", map4); std::map map5{std::from_range, std::views::zip(std::views::iota(1), vec)}; std::println("map5: {}", map5); }