std::mdspan
std::mdspan
, introduced in the C++23 standard, is a multidimensional span template class that extends the concept of std::span
to multiple dimensions. It provides a view of a multidimensional contiguous sequence of elements without owning the underlying data. This class is handy for numerical computations and algorithms that operate on multidimensional data structures, such as matrices and tensors.
Purpose and suitability
std::mdspan
is a multidimensional span in the C++ STL. It is a non-owning view of a multidimensional array, offering efficient access and manipulation.
Its strengths are as follows:
- Representing and accessing multidimensional data without owning it
- Facilitating interoperability with other languages and libraries that work with multidimensional arrays
std::mdspan
is particularly suitable in the following scenarios:
- When you must work with multidimensional data from other libraries or APIs without copying
- When you...