Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions stl/inc/mdspan
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ public:
&& conjunction_v<is_convertible<_IndexTypes, index_type>...,
is_nothrow_constructible<index_type, _IndexTypes>...>
_NODISCARD constexpr index_type operator()(_IndexTypes... _Indices) const noexcept {
return _Index_impl(make_index_sequence<extents_type::rank()>{}, static_cast<index_type>(_Indices)...);
return _Index_impl(
make_index_sequence<extents_type::rank()>{}, static_cast<index_type>(_STD move(_Indices))...);
}

_NODISCARD static constexpr bool is_always_unique() noexcept {
Expand Down Expand Up @@ -727,7 +728,8 @@ public:
&& conjunction_v<is_convertible<_IndexTypes, index_type>...,
is_nothrow_constructible<index_type, _IndexTypes>...>
_NODISCARD constexpr index_type operator()(_IndexTypes... _Indices) const noexcept {
return _Index_impl(make_index_sequence<extents_type::rank()>{}, static_cast<index_type>(_Indices)...);
return _Index_impl(
make_index_sequence<extents_type::rank()>{}, static_cast<index_type>(_STD move(_Indices))...);
}

_NODISCARD static constexpr bool is_always_unique() noexcept {
Expand Down Expand Up @@ -975,7 +977,8 @@ public:
&& conjunction_v<is_convertible<_IndexTypes, index_type>...,
is_nothrow_constructible<index_type, _IndexTypes>...>
_NODISCARD constexpr index_type operator()(_IndexTypes... _Indices) const noexcept {
return _Index_impl(make_index_sequence<extents_type::rank()>{}, static_cast<index_type>(_Indices)...);
return _Index_impl(
make_index_sequence<extents_type::rank()>{}, static_cast<index_type>(_STD move(_Indices))...);
}

_NODISCARD static constexpr bool is_always_unique() noexcept {
Expand Down
17 changes: 17 additions & 0 deletions tests/std/tests/P0009R18_mdspan_layout_left/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,23 @@ constexpr void check_call_operator() {
assert(m3(1, 2) == 11);
assert(m3(4, 5) == 29);
}

{ // LWG-4314: Missing move in mdspan layout mapping::operator()
struct LwgIndex {
constexpr operator int() & noexcept {
return 0;
}

constexpr operator int() && noexcept {
return 1;
}
};

layout_left::mapping<extents<int, 2>> m;
LwgIndex idx;
assert(m(idx) == 1);
assert(m(LwgIndex{}) == 1);
}
}

constexpr void check_stride_function() {
Expand Down
17 changes: 17 additions & 0 deletions tests/std/tests/P0009R18_mdspan_layout_right/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,23 @@ constexpr void check_call_operator() {
assert(m3(2, 2) == 12);
assert(m3(3, 4) == 19);
}

{ // LWG-4314: Missing move in mdspan layout mapping::operator()
struct LwgIndex {
constexpr operator int() & noexcept {
return 1;
}

constexpr operator int() && noexcept {
return 0;
}
};

layout_right::mapping<extents<int, 2>> m;
LwgIndex idx;
assert(m(idx) == 0);
assert(m(LwgIndex{}) == 0);
}
}

constexpr void check_stride_function() {
Expand Down
17 changes: 17 additions & 0 deletions tests/std/tests/P0009R18_mdspan_layout_stride/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,23 @@ constexpr void check_call_operator() {
assert(m4(1, 1, 1) == 19);
assert(m4(1, 2, 4) == 29);
}

{ // LWG-4314: Missing move in mdspan layout mapping::operator()
struct LwgIndex {
constexpr operator int() & noexcept {
return 0;
}

constexpr operator int() && noexcept {
return 1;
}
};

layout_stride::mapping<extents<int, 3>> m({}, array{2});
LwgIndex idx;
assert(m(idx) == 2);
assert(m(LwgIndex{}) == 2);
}
}

constexpr void check_stride_function() {
Expand Down