]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix forwarding of custom IndexType in mdspan [PR121061]
authorLuc Grosheintz <luc.grosheintz@gmail.com>
Wed, 16 Jul 2025 13:45:45 +0000 (15:45 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Thu, 17 Jul 2025 14:12:52 +0000 (16:12 +0200)
commit29d53f6213e0a1569aa8ca9db613b48df642986c
treef96291876c46ceb471f9f585ed56565d735ad1a9
parent1eee8430794f790b6d364603685e70d83d8d42f5
libstdc++: Fix forwarding of custom IndexType in mdspan [PR121061]

The second bug report in PR121061 is that the conversion of custom
OtherIndexType to IndexType is incorrectly not done via r-value
references.

This commit fixes the forwarding issue, adds a custom IndexType called
RValueInt, which only allows conversion to int via r-value reference.

PR libstdc++/121061

libstdc++-v3/ChangeLog:

* include/std/mdspan (extents::extents): Perform conversion to
index_type of an r-value reference.
(layout_left::mapping::operator()): Ditto.
(layout_right::mapping::operator()): Ditto.
(layout_stride::mapping::operator()): Ditto.
* testsuite/23_containers/mdspan/extents/custom_integer.cc: Add
tests for RValueInt and MutatingInt.
* testsuite/23_containers/mdspan/int_like.h (RValueInt): Add.
* testsuite/23_containers/mdspan/layouts/mapping.cc: Test with
RValueInt.
* testsuite/23_containers/mdspan/mdspan.cc: Ditto.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
libstdc++-v3/include/std/mdspan
libstdc++-v3/testsuite/23_containers/mdspan/extents/custom_integer.cc
libstdc++-v3/testsuite/23_containers/mdspan/int_like.h
libstdc++-v3/testsuite/23_containers/mdspan/layouts/mapping.cc
libstdc++-v3/testsuite/23_containers/mdspan/mdspan.cc