This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4372. Weaken Mandates: for dynamic padding values in padded layouts

Section: 23.7.3.4.8.1 [mdspan.layout.leftpad.overview], 23.7.3.4.9.1 [mdspan.layout.rightpad.overview] Status: New Submitter: Luc Grosheintz Opened: 2025-09-09 Last modified: 2025-09-19

Priority: Not Prioritized

View all issues with New status.

Discussion:

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 23.7.3.4.8.1 [mdspan.layout.leftpad.overview] (5.2) and 23.7.3.4.9.1 [mdspan.layout.rightpad.overview] (5.2), respectively) requires (unconditionally) that

Since std::dynamic_extent is defined as size_t(-1) (in 23.7.2.1 [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.

Proposed resolution:

This wording is relative to N5014.

  1. Modify 23.7.3.4.8.1 [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 23.7.3.4.9.1 [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) — […]