kokkos / mdspan

Reference implementation of mdspan targeting C++23
Other
413 stars 69 forks source link

mdarray: Add CTAD from possibly multidimensional C array #329

Open mhoemmen opened 6 months ago

mhoemmen commented 6 months ago

Make mdarray CTAD from a possibly multidimensional C array behave as expected.

Example:

float values[5][7][11] {};
mdarray m{values};
static_assert(m.rank() == 3);
static_assert(m.static_extent(0) == 5);
static_assert(m.static_extent(1) == 7);
static_assert(m.static_extent(2) == 11);
assert(m.extent(0) == 5);
assert(m.extent(1) == 7);
assert(m.extent(2) == 11);

This is just a draft, because it uses requires instead of MDSPAN_FUNCTION_REQUIRES. The latter doesn't seem to work like it used to. I really just want to show that this is possible.