]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Restructure mdspan tests to reuse IntLike.
authorLuc Grosheintz <luc.grosheintz@gmail.com>
Fri, 4 Jul 2025 08:29:45 +0000 (10:29 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Tue, 8 Jul 2025 11:47:41 +0000 (13:47 +0200)
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.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
libstdc++-v3/testsuite/23_containers/mdspan/extents/custom_integer.cc
libstdc++-v3/testsuite/23_containers/mdspan/extents/int_like.h [new file with mode: 0644]

index 2907ad12ae722432053f0e793c2c0a27990d512b..404755bd5ac4494e59d6764a9f51ae024d1a482b 100644 (file)
@@ -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 (file)
index 0000000..f39f4cc
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef TEST_MDSPAN_INT_LIKE_H
+#define TEST_MDSPAN_INT_LIKE_H
+
+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;
+};
+
+#endif // TEST_MDSPAN_INT_LIKE_H