On Mon, 7 Jul 2025 at 09:59, Tomasz Kaminski <tkami...@redhat.com> wrote: > > > On Fri, Jul 4, 2025 at 10:37 AM Luc Grosheintz <luc.groshei...@gmail.com> > wrote: >> >> The class IntLike is used for testing extents with user-defined classes >> that convert to int. This commit places the class into a separate header >> file. This allows it to be reused across different parts of the mdspan >> related testsuite. >> >> libstdc++-v3/ChangeLog: >> >> * testsuite/23_containers/mdspan/extents/custom_integer.cc: >> Delete IntLike and include "int_like.h". >> * testsuite/23_containers/mdspan/extents/int_like.h: Add >> IntLike. >> >> Signed-off-by: Luc Grosheintz <luc.groshei...@gmail.com> >> --- > > LGTM, outside of using header guards. I can change that locally.
Yes please. OK for trunk with the guards. >> >> .../mdspan/extents/custom_integer.cc | 27 +----------------- >> .../23_containers/mdspan/extents/int_like.h | 28 +++++++++++++++++++ >> 2 files changed, 29 insertions(+), 26 deletions(-) >> create mode 100644 >> libstdc++-v3/testsuite/23_containers/mdspan/extents/int_like.h >> >> diff --git >> a/libstdc++-v3/testsuite/23_containers/mdspan/extents/custom_integer.cc >> b/libstdc++-v3/testsuite/23_containers/mdspan/extents/custom_integer.cc >> index 2907ad12ae7..404755bd5ac 100644 >> --- a/libstdc++-v3/testsuite/23_containers/mdspan/extents/custom_integer.cc >> +++ b/libstdc++-v3/testsuite/23_containers/mdspan/extents/custom_integer.cc >> @@ -2,38 +2,13 @@ >> #include <mdspan> >> >> #include <testsuite_hooks.h> >> +#include "int_like.h" >> >> // Test construction from a custom integer-like object, that has >> // no copy/move ctor or copy/move assignment operator. >> >> constexpr size_t dyn = std::dynamic_extent; >> >> -class IntLike >> -{ >> -public: >> - explicit >> - IntLike(int i) >> - : _M_i(i) >> - { } >> - >> - IntLike() = delete; >> - IntLike(const IntLike&) = delete; >> - IntLike(IntLike&&) = delete; >> - >> - const IntLike& >> - operator=(const IntLike&) = delete; >> - >> - const IntLike& >> - operator=(IntLike&&) = delete; >> - >> - constexpr >> - operator int() const noexcept >> - { return _M_i; } >> - >> -private: >> - int _M_i; >> -}; >> - >> static_assert(std::is_convertible_v<IntLike, int>); >> static_assert(std::is_nothrow_constructible_v<int, IntLike>); >> >> diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/extents/int_like.h >> b/libstdc++-v3/testsuite/23_containers/mdspan/extents/int_like.h >> new file mode 100644 >> index 00000000000..7785d2ffe95 >> --- /dev/null >> +++ b/libstdc++-v3/testsuite/23_containers/mdspan/extents/int_like.h >> @@ -0,0 +1,28 @@ >> +#pragma once > > Please use header guards instead of pragma once. >> >> + >> +class IntLike >> +{ >> +public: >> + explicit >> + IntLike(int i) >> + : _M_i(i) >> + { } >> + >> + IntLike() = delete; >> + IntLike(const IntLike&) = delete; >> + IntLike(IntLike&&) = delete; >> + >> + const IntLike& >> + operator=(const IntLike&) = delete; >> + >> + const IntLike& >> + operator=(IntLike&&) = delete; >> + >> + constexpr >> + operator int() const noexcept >> + { return _M_i; } >> + >> +private: >> + int _M_i; >> +}; >> + >> -- >> 2.49.0 >>