Dear libstdc++ devs,

While adding the checking of mandates/prerequisites I
noticed that:

    7. N5014 requires that for a strided_slice either:
    slice.extent == 0 or slice.stride > 0.

    However, in P3663, the condition is split into:
      + constants (8.4.5.3.2): if slice.extent and slice.stride
         are constant_wrappers, then slice.stride > 0.
      + runtime (8.4.10.3): either slice.extent == 0 or
        slice.stride > 0.

Is this intentional? Essentially, AFAICT,
  strided_slice{0, cw<0>, cw<0>}; // invalid
  strided_slice{0, 0, 0}; // valid

Kind regards,
Luc

On 10/31/25 9:06 AM, Luc Grosheintz wrote:
Dear libstdc++ devs,

While working on P3663, the following questions arose:

   1. What are the requirements for user provided integer-like objects
      (when used as slices)? Do they need to have copy and move ctors?
      There's a few locations where non-canonicalized slices are copied,
      e.g. when passed to `submdspan_canonical_slices`.

   2. What happens if in the future the standard wants to add a new kind
      of *canonical* selection? For example, block-wise selection: pick
      N, skip M, pick N, skip M, etc. This can't be expressed by any of
      the current canonical slices (currently there's also no layout to
      express this idea, but presumably it would be added at the same
      time).

   3. Is there a way to `static_assert` the mandate that something is a
      "submdspan slice type for IndexType"?

   4. The notion of "unit-stride slice" is false for pairs and tuples,
      even though they intuitively have unit strides. By renaming the
      concept "canonical unit-stride slice", the name would match my
      intuition again.

   5. There's a notion of "lower bound of the submdspan slice range"
      which is also used in contexts where the slice could be empty, e.g.
      `strided_slice(n, 0, 1)`. This represents the same empty interval
      regardless of the value of `n`, the question is what is the "lower
      bound"? Concretely, let `n == exts[i]`. Then, is `pair{n, n}` a
      valid slice for dimension `i`? It sounds like yes, because the
      condition:
        > the kth interval of e contains the submdspan slice range of s
          for the kth extent of e;
     is satisfied due to the interval being empty. By the same logic,
     `pair{n+1, n+1}` should also be valid, but `pair{cw<n+1>, cw<n+1>}`
     isn't, because it's not a slice type for the kth extent.

   6. I'd like to suggest adding "canonical" to "valid submdspan slice
      for the kth extent of e", because:
      - a "submdspan slice type for IndexType" is not required to be
        canonical,
      - there's a couple of related concepts that explicitly mention the
        word canonical,
      - it makes it harder to know when `SliceSpecifiers` refer to
        canonical slices, since that property isn't mentioned and only
        implied by "valid submdspan slice for the kth extent of e".

Typos:
   * In 8.15.2, `src` should be `src.extents()`.

Kind regards,
Luc

Reply via email to