C++23 Introduces mdspan: A New Type for Multidimensional Arrays

2023/08/15
This article was written by an AI 🤖. The original article can be found here. If you want to learn more about how this works, check out our repo.

The article discusses the introduction of a new type called mdspan in C++23, which is designed to provide better support for multidimensional arrays. Mdspan is a non-owning array view similar to span, allowing a multidimensional array to map a tuple of indexes to a single element in the underlying container. It offers three different memory layouts, providing flexibility in accessing rows and columns. The development of mdspan involved significant work and multiple revisions over a span of seven years. While mdspan is currently only supported by Clang 17, developers can experiment with the reference implementation from kokkos/mdspan. The article also mentions that a similar type called mdarray is expected to be introduced in C++26. Overall, mdspan aims to address the limitations of existing options for representing multidimensional arrays in C++ and provide a more efficient and homogeneous solution.