ORNL / ORNL/cpp-proposals-pub

mdspan: Using `layout_stride` directly is horrific

Open
#110 0 comments 0 reactions 3 assignees View on GitHub

@crtrott is already working on this.

Since Aug 5, 2019.

subject - mdspan (P0009)
Dominant language
HTML
Stars
29
Forks
26
PR merge metrics
No merged PRs in 30d

Description

For instance, the constructor requires you to repeat the extents three times. For a 4D mdspan with sizes 20, dynamic, 40, dynamic, this looks like:

auto s =
  std::basic_mdspan<
    int, std::extents<20, std::dynamic_extent, 40, std::dynamic_extent>, std::layout_stride
  >(
    ptr,
    std::layout_stride::mapping<
      std::extents<20, std::dynamic_extent, 40, std::dynamic_extent>
    >(
      std::extents<20, std::dynamic_extent, 40, std::dynamic_extent>{30, 50},
      std::array<ptrdiff_t, 4>{1, 20, 600, 2400}
    )
  );

Either we should have some extension to the mdspan constructors that makes this friendlier or we should make layout_stride an implementation detail of subspan for now. Either of these options are fine—layout_stride doesn't need to be in the first version if it's this difficult to use (subspan can just return an implementation-defined layout, which it should probably do anyway).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.