mdspan icon indicating copy to clipboard operation
mdspan copied to clipboard

[feature-request] CTAD for `mdspan` from `mdarray`

Open ericniebler opened this issue 8 months ago • 2 comments

it would be groovy if i could create an mdspan from an mdarray like mdspan{array}. something like this might work:

//! \brief Deduction guide for \c ::std::mdspan that makes its template parameters
//! deducable from a \c ::std::experimental::mdarray.
template <class ElementType, class Extents, class LayoutPolicy, class Container>
mdspan(experimental::mdarray<ElementType, Extents, LayoutPolicy, Container>&)
  -> mdspan<ElementType, Extents, LayoutPolicy>;

//! \overload
template <class ElementType, class Extents, class LayoutPolicy, class Container>
mdspan(const experimental::mdarray<ElementType, Extents, LayoutPolicy, Container>&)
  -> mdspan<const ElementType, Extents, LayoutPolicy>;

ericniebler avatar Apr 14 '25 21:04 ericniebler

Yeah definitely on the todo list. We got stuck with mdarray for a bit but I do want to revive it because I think it's just a huge usability improvement.

crtrott avatar Apr 14 '25 22:04 crtrott

@crtrott I'd love to redo the paper completely, making the static-allocation + all-static-extents case a container like std::array, and replacing the dynamic-allocation case with unique_mdarray.

mhoemmen avatar Apr 14 '25 22:04 mhoemmen