[gcc r16-2095] libstdc++: Restructure mdspan tests to reuse IntLike.
Tomasz Kaminski
tkaminsk@gcc.gnu.org
Tue Jul 8 11:48:31 GMT 2025
https://gcc.gnu.org/g:45b81ebf7815e3cea15f6fb18e83a101a4c50fb3
commit r16-2095-g45b81ebf7815e3cea15f6fb18e83a101a4c50fb3
Author: Luc Grosheintz <luc.grosheintz@gmail.com>
Date: Fri Jul 4 10:29:45 2025 +0200
libstdc++: Restructure mdspan tests to reuse IntLike.
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>
Diff:
---
.../23_containers/mdspan/extents/custom_integer.cc | 27 +------------------
.../23_containers/mdspan/extents/int_like.h | 30 ++++++++++++++++++++++
2 files changed, 31 insertions(+), 26 deletions(-)
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 2907ad12ae72..404755bd5ac4 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 000000000000..f39f4cc90816
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/mdspan/extents/int_like.h
@@ -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
More information about the Libstdc++-cvs
mailing list