Title
Weaken Mandates: for dynamic padding values in padded layouts
Status
wp
Section
[mdspan.layout.leftpad.overview] [mdspan.layout.rightpad.overview]
Submitter
Luc Grosheintz

Created on 2025-09-09.00:00:00 last changed 5 days ago

Messages

Date: 2025-11-11.10:48:16

Proposed resolution:

This wording is relative to N5014.

  1. Modify [mdspan.layout.leftpad.overview] as indicated:

    -5- Mandates:

    1. (5.1) — […]

    2. (5.2) — if `padding_value` is not equal to `dynamic_extent`, then `padding_value` is representable as a value of type `index_type`.

    3. (5.3) — […]

    4. (5.4) — […]

  2. Modify [mdspan.layout.rightpad.overview] as indicated:

    -5- Mandates:

    1. (5.1) — […]

    2. (5.2) — if `padding_value` is not equal to `dynamic_extent`, then `padding_value` is representable as a value of type `index_type`.

    3. (5.3) — […]

    4. (5.4) — […]

Date: 2025-11-11.10:48:16

[ Kona 2025-11-08; Status changed: Voting → WP. ]

Date: 2025-10-15.00:00:00

[ 2025-10-17; Reflector poll. ]

Set status to Tentatively Ready after six votes in favour during reflector poll.

"This matches the wording in [mdspan.extents.overview] 1.2"

Date: 2025-09-09.00:00:00

Two new layouts were added to <mdspan> in C++26. Both have a template parameter `size_t PaddingValue`. This value is allowed to be `std::dynamic_extent` to signal that the padding value isn't known at compile time.

A class Mandates: element (in [mdspan.layout.leftpad.overview] (5.2) and [mdspan.layout.rightpad.overview] (5.2), respectively) requires (unconditionally) that

  • `PaddingValue` is representable as a value of `index_type`.

Since `std::dynamic_extent` is defined as `size_t(-1)` (in [span.syn]) this immediately prohibits all dynamically padded layout mappings for any `index_type` for which:

numeric_limit<index_type>::max() < numeric_limit<size_t>::max()

One example is `int` on a 64-bit system.

The proposed resolution states that the modified representability Mandates: element holds for rank <= 1, even though in that case the `PaddingValue` has no other effect. Hence, the Mandates: element could be weakened further.

History
Date User Action Args
2025-11-11 10:48:16adminsetmessages: + msg15645
2025-11-11 10:48:16adminsetstatus: voting -> wp
2025-10-30 17:45:31adminsetstatus: ready -> voting
2025-10-17 14:12:23adminsetmessages: + msg15219
2025-10-17 14:12:23adminsetstatus: new -> ready
2025-09-19 17:16:15adminsetmessages: + msg15061
2025-09-09 00:00:00admincreate