//******************************************************** // 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 // for std::pair #include void printPairRange(auto&& rg) { std::println(" default: {}", rg); std::println(" {{:m}} : {:m}", rg); std::println(" {{::m}} : {::m}", rg); std::println(" {{::n}} : {::n}", rg); std::println(" {{:n}} : {:n}", rg); std::println(" {{:n:m}} : {:n:m}", rg); std::println(" {{:n:n}} : {:n:n}", rg); } int main() { // ranges of pairs: std::println("map:"); std::map map{{1, 'a'}, {2, 'b'}, {3, 'c'}}; printPairRange(map); std::println("\nView on map:"); printPairRange(map | std::views::all); std::println("\nvector>:"); std::vector> vecp{{1, 'a'}, {2, 'b'}, {3, 'c'}}; printPairRange(vecp); }