In C++, an mdspan is a non-owning, multi-dimensional view of (typically contiguous) typed data in memory.
Questions tagged [mdspan]
7 questions
5
votes
2 answers
How do I iterate an mdspan?
So, I decided I want to use mdspan's rather than a span + element access function. But - one obvious thing one would want to do with an (md)span is iterate its elements. This works for spans:
std::vector vec = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12…

einpoklum
- 118,144
- 57
- 340
- 684
3
votes
0 answers
Accessing a row of a std::mdspan as std::span
I'm trying out the Kokkos reference mdspan implementation to see if it could be used to simplify some bits of code in our codebase. One thing that I would have intuitively assumed to be possible is to pick a row of a two dimensional std::mdspan and…

PluginPenguin
- 1,576
- 11
- 25
3
votes
1 answer
What is an mdspan, and what is it used for?
Over the past year or so I've noticed a few C++-related answers on StackOverflow refer to mdspan's - but I've never actually seen these in C++ code. I tried looking for them in my C++ compiler's standard library directory and in the C++ coding…

einpoklum
- 118,144
- 57
- 340
- 684
2
votes
0 answers
std::mdspan stride layout policy
I'd like to understand how the std::layout_stride policy for the std::mdspan works. At this point, no compiler supports this new C++23 library type, although a reference implementation exists: https://github.com/kokkos/mdspan. However, I could not…

Marius Bancila
- 16,053
- 9
- 49
- 91
2
votes
0 answers
Object that stores multidimensional index that can be supplied in operator[]
As C++23 supports multidimensional subscript operator(eg. a[1, 2, 3] and mdspan, is there native support for storing an multidimensional index as an object and used multiple times?
One example could be
// not storing as object {int a; double b;} due…

user122049
- 397
- 1
- 11
2
votes
0 answers
why does the mdspan accessor policy concept contain a decay member?
I am looking forward to the proposed mdspan, and was thinking of a toy example. What I thought of was game of life, which works on a binary 2d array. Naturally I would like to use an mdspan over a bitset or std::vector, both of which address…

maddanio
- 87
- 5
1
vote
1 answer
Is there an equivalent of submdspan for mdarray?
The repo of the exciting mdspan, a multi-dimensional analogue of std::span suggested for the C++ standard libraries, now also contains a reference implementation of the closely-related mdarray, which unlike mdspan owns its data.
But whereas the…

Simplex
- 930
- 1
- 9
- 20