Details of std::mdspan from C++23 -- Bartlomiej Filipek
In this article, we’ll see details of
std::mdspan,
a new view type tailored to multidimensional data. We’ll go through type declaration, creation techniques, and options to customize the internal functionality.
Details of
std::mdspan
from C++23by Bartlomiej Filipek
From the article:
In this article, we’ll see details of
std::mdspan,
a new view type tailored to multidimensional data. We’ll go through type declaration, creation techniques, and options to customize the internal functionality.Type declaration
The type is declared in the following way:
template< class T, class Extents, class LayoutPolicy = std::layout_right, class AccessorPolicy = std::default_accessor<T> > class mdspan;
And it has its own header
<mdspan>
.The main proposal for this feature can be found at https://wg21.link/P0009
Following the pattern from
std::span
, we have a few options to createmdspan
: with dynamic or static extent.The key difference is that rather than just one dimension, we can specify multiple. The declaration also gives more options in the form of
LayoutPolicy
andAccessorPolicy
. More on that later.