//******************************************************** // 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 int main() { std::array arr{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; // mdspan with 1 dimension and no elements: std::mdspan mds1{arr.data(), 0}; std::println("rank: {}", mds1.rank()); std::println("size: {}", mds1.size()); std::println("empty: {}\n", mds1.empty()); // mdspan with 1 dimension and no elements and fixed extent: std::mdspan> mdsf1{arr.data()}; std::println("rank: {}", mdsf1.rank()); std::println("size: {}", mdsf1.size()); std::println("empty: {}\n", mdsf1.empty()); // mdspan with 0 dimensions: std::mdspan mds0{arr.data()}; std::println("rank: {}", mds0.rank()); std::println("size: {}", mds0.size()); std::println("empty: {}\n", mds0.empty()); // mdspan with 0 dimensions and fixed extent: std::mdspan> mdsf0{arr.data()}; std::println("rank: {}", mdsf0.rank()); std::println("size: {}", mdsf0.size()); std::println("empty: {}", mdsf0.empty()); }