The following code example is taken from the book
C++23 - The Complete Guide
by Nicolai M. Josuttis,
Leanpub, 2026
The code is licensed under a
Creative Commons Attribution 4.0 International License.
// raw code
#include <print>
void print3D(const auto& mds)
{
std::print("3D mdspan ({}*{}*{}):\n", mds.extent(0), mds.extent(1),
mds.extent(2));
for(std::size_t i = 0; i < mds.extent(0); ++i) {
std::print(" ");
for(std::size_t j = 0; j < mds.extent(1); ++j) {
for(std::size_t k = 0; k < mds.extent(2); ++k) {
std::print("{} ", mds[i, j, k]);
}
std::print("\n ");
}
std::print("\n");
}
}