This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Tentatively Ready status.
extents::index-cast weirdnessSection: 23.7.3.3.2 [mdspan.extents.expo] Status: Tentatively Ready Submitter: Casey Carter Opened: 2023-11-29 Last modified: 2025-10-17
Priority: Not Prioritized
View all issues with Tentatively Ready status.
Discussion:
The exposition-only static member index-cast of extents is specified as
(23.7.3.3.2 [mdspan.extents.expo]/9):
template<class OtherIndexType> static constexpr auto index-cast(OtherIndexType&& i) noexcept;-9- Effects:
(9.1) — If
OtherIndexTypeis an integral type other thanbool, then equivalent toreturn i;,(9.2) — otherwise, equivalent to
return static_cast<index_type>(i);.[Note 1: This function will always return an integral type other than
bool. Since this function's call sites are constrained on convertibility ofOtherIndexTypetoindex_type, integer-class types can use thestatic_castbranch without loss of precision. — end note]
This function returns T when passed an rvalue of cv-unqualified integral type T,
but index_type when passed a cv-qualified and/or lvalue argument of any integral type. It
would seem more consistent and easier to reason about if 9.1 was instead conditional on
remove_cvref_t<OtherIndexType>.
[2025-10-17; Reflector poll.]
Set status to Tentatively Ready after eight votes in favour during reflector poll.
"Doesn't matter in this case, but logically decay_t seems like a better fit."
Proposed resolution:
This wording is relative to N4964.
Modify 23.7.3.3.2 [mdspan.extents.expo] as indicated:
template<class OtherIndexType> static constexpr auto index-cast(OtherIndexType&& i) noexcept;-9- Effects:
(9.1) — If
remove_cvref_t<OtherIndexType>is an integral type other thanbool, then equivalent toreturn i;,(9.2) — otherwise, equivalent to
return static_cast<index_type>(i);.[Note 1: This function will always return an integral type other than
bool. Since this function's call sites are constrained on convertibility ofOtherIndexTypetoindex_type, integer-class types can use thestatic_castbranch without loss of precision. — end note]