Skip to content

Implement LWG-4314: Missing move in mdspan layout mapping::operator()#6244

Open
JMazurkiewicz wants to merge 3 commits intomicrosoft:mainfrom
JMazurkiewicz:lwg4314
Open

Implement LWG-4314: Missing move in mdspan layout mapping::operator()#6244
JMazurkiewicz wants to merge 3 commits intomicrosoft:mainfrom
JMazurkiewicz:lwg4314

Conversation

@JMazurkiewicz
Copy link
Copy Markdown
Contributor

This PR implements changes to [mdspan.layout.left.obs], [mdspan.layout.right.obs], and [mdspan.layout.stride.obs]. Other changes cannot be addressed here, because:

  • We don't implement padded layouts,
  • We already have call to std::forward in _Mdspan_checked_index_cast:

    STL/stl/inc/mdspan

    Lines 1225 to 1237 in da06be8

    template <class _IndexType, class _OtherIndexType>
    _NODISCARD constexpr _IndexType _Mdspan_checked_index_cast(_OtherIndexType&& _Idx)
    noexcept(is_nothrow_constructible_v<_IndexType, _OtherIndexType>) {
    _STL_INTERNAL_STATIC_ASSERT(is_integral_v<_IndexType> && is_constructible_v<_IndexType, _OtherIndexType>);
    using _Arg_value_t = remove_cvref_t<_OtherIndexType>;
    if constexpr (is_integral_v<_Arg_value_t> && !is_same_v<_Arg_value_t, bool>) {
    _STL_VERIFY(_STD in_range<_IndexType>(_Idx),
    "Each argument to operator[] must be representable by index_type in order for the pack of arguments to be "
    "a valid multidimensional index (N4964 [mdspan.mdspan.members]/3).");
    }
    return static_cast<_IndexType>(_STD forward<_OtherIndexType>(_Idx));
    }
  • Effect of std::forward in other occurrences of index-cast should not be observable by users.

I think we should close #6209 and mention LWG-4314 in #3807.

@JMazurkiewicz JMazurkiewicz requested a review from a team as a code owner April 10, 2026 13:15
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Apr 10, 2026
@StephanTLavavej StephanTLavavej added LWG Library Working Group issue mdspan C++23 mdspan labels Apr 10, 2026
@StephanTLavavej
Copy link
Copy Markdown
Member

Thanks, I've updated #3807 as you suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LWG Library Working Group issue mdspan C++23 mdspan

Projects

Status: Initial Review

Development

Successfully merging this pull request may close these issues.

LWG-4314 Missing move in mdspan layout mapping::operator()

2 participants