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.
layout_stride::mapping
should treat empty mappings as exhaustiveSection: 23.7.3.4.7 [mdspan.layout.stride] Status: New Submitter: Tomasz KamiĆski Opened: 2025-05-22 Last modified: 2025-05-24
Priority: Not Prioritized
View all other issues in [mdspan.layout.stride].
View all issues with New status.
Discussion:
Mapping over an empty multidimensional index space is always exhaustive according to the corresponding definitions from 23.7.3.4.2 [mdspan.layout.reqmts] p16.
However, the current specification oflayout_stride::mapping
does not consider whether
some of the empty multidimensional index spaces are unique or exhaustive. For illustration,
the mapping with the following configuration is not considered exhaustive according to the
current specification of 23.7.3.4.7.4 [mdspan.layout.stride.obs] bullet 5.2:
extents: 2, 2, 0 strides: 2, 6, 20
This prevents the implementation from implementing sm.is_exhaustive()
as
sm.fwd-prod-of-extents(sm::extents_type::rank()) == sm.required_span_size()
.
For all mappings with size greater than zero, such an expression provides an answer consistent
with the standard. However, it always returns true
for an empty mapping, such as shown
in the example.
is_exhaustive()
to return
true
for empty mappings.
For consistency, we could update is_always_exhaustive()
to recognize mapping with
rank() == 0
, and one for which at least one of the static extents is equal to zero
(i.e., they always represent a multidimensional index space).
Proposed resolution:
This wording is relative to N5008.
Modify 23.7.3.4.7.1 [mdspan.layout.stride.overview] as indicated:
namespace std { template<class Extents> class layout_stride::mapping { […] static constexpr bool is_always_unique() noexcept { return true; } static constexpr bool is_always_exhaustive() noexcept;{ return false; }; static constexpr bool is_always_strided() noexcept { return true; } […] }; }
Modify 23.7.3.4.7.4 [mdspan.layout.stride.obs] as indicated:
[…]
static constexpr bool is_always_exhaustive() noexcept;-?- Returns:
true
ifrank_
is0
or if there is a rank indexr
ofextents()
such thatextents_type::static_extent(r)
is0
, otherwisefalse
.constexpr bool is_exhaustive() const noexcept;-5- Returns:
(5.1) —
true
ifrank_
or the size of the multidimensional index spacem.extents()
is0
.(5.2) — […]
(5.3) — […]