//********************************************************
// 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 <print>
#include <array>
#include <mdspan>
#include "print2d.hpp"

int main()
{
  std::array<double, 10> arr{};

  // mdspan with rows of 3 values:
  std::mdspan mds{arr.data(), arr.size() / 3, 3};

  // set values in the mdspan:
  for (unsigned i=0; i != mds.extent(0); i++) {
    for (unsigned j=0; j != mds.extent(1); j++) {
      mds[i, j] = 100 * i + j * 0.1;
    }
  }

  print2D(mds);                    // print the mdspan

  std::println("array: {}", arr);  // print the referenced array
}

