//******************************************************** // 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 #include #include #include int main() { // sequential containers: std::println("vector: {}", std::vector{"tic", "tac", "toe"}); std::println("list: {}", std::list{"tic", "tac", "toe"}); std::string arr[] = {"tic", "tac", "toe"}; std::println("raw array: {}", arr); std::println("string: {}\n", std::string{"abc"}); // associative containers: std::set set{"tic", "tac", "toe"}; std::println("set: {}", set); std::println("unordered set: {}\n", std::unordered_set{"tic", "tac", "toe"}); // key/value containers: std::map map{{1, 'a'}, {2, 'b'}, {3, 'c'}}; std::unordered_map umap{{1, 'a'}, {2, 'b'}, {3, 'c'}}; std::println("map: {}", map); std::println("unordered map: {}\n", umap); // views switch to layout of vectors (of pairs): std::println("view on set: {}", set | std::views::all); std::println("view on map: {}", map | std::views::all); }