cpp-proposals-pub icon indicating copy to clipboard operation
cpp-proposals-pub copied to clipboard

mdspan: Using `layout_stride` directly is horrific

Open dhollman opened this issue 6 years ago • 0 comments

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).

dhollman avatar Aug 05 '19 21:08 dhollman