]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Strengthen exception guarantee for mdspan methods.
authorLuc Grosheintz <luc.grosheintz@gmail.com>
Mon, 21 Jul 2025 11:07:36 +0000 (13:07 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Mon, 21 Jul 2025 15:45:37 +0000 (17:45 +0200)
commit03437196942b03eee4f3f3edfaf201f5bdc37d9e
treee77b44a064a5b8ef34c7f690b10d1e3c79be512c
parentb441d735c092f5d60c4a9c7167ed9153003d49fa
libstdc++: Strengthen exception guarantee for mdspan methods.

The mdspan::is_{,always}_{unique,strided,exhaustive} methods only call
their counterparts in mdspan::mapping_type. The standard specifies that
the methods of mdspan::mapping_type are noexcept, but doesn't specify if
the methods of mdspan are noexcept.

Libc++ strengthened the exception guarantee for these mdspan methods.
This commit conditionally strengthens these methods for libstdc++.

libstdc++-v3/ChangeLog:

* include/std/mdspan (mdspan::is_always_unique): Make
conditionally noexcept.
(mdspan::is_always_exhaustive): Ditto.
(mdspan::is_always_strided): Ditto.
(mdspan::is_unique): Ditto.
(mdspan::is_exhaustive): Ditto.
(mdspan::is_strided): Ditto.
* testsuite/23_containers/mdspan/layout_like.h: Make noexcept
configurable. Add ThrowingLayout.
* testsuite/23_containers/mdspan/mdspan.cc: Add tests for
noexcept.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
libstdc++-v3/include/std/mdspan
libstdc++-v3/testsuite/23_containers/mdspan/layout_like.h
libstdc++-v3/testsuite/23_containers/mdspan/mdspan.cc