template<typename _IndexType, size_t... _Extents>
class extents
{
- static_assert(is_integral_v<_IndexType>, "_IndexType must be integral.");
+ static_assert(__is_standard_integer<_IndexType>::value,
+ "IndexType must be a signed or unsigned integer type");
static_assert(
(__mdspan::__valid_static_extent<_Extents, _IndexType> && ...),
- "Extents must either be dynamic or representable as _IndexType");
+ "Extents must either be dynamic or representable as IndexType");
public:
using index_type = _IndexType;
// { dg-do compile { target c++23 } }
#include<mdspan>
-std::extents<char, size_t(1) << 9> e1; // { dg-error "from here" }
-std::extents<double, 1> e2; // { dg-error "from here" }
-// { dg-prune-output "dynamic or representable as _IndexType" }
-// { dg-prune-output "must be integral" }
+#include <cstdint>
+
+std::extents<uint8_t, size_t(1) << 9> e1; // { dg-error "from here" }
+std::extents<char, 1> e2; // { dg-error "from here" }
+std::extents<bool, 1> e3; // { dg-error "from here" }
+std::extents<double, 1> e4; // { dg-error "from here" }
+// { dg-prune-output "dynamic or representable as IndexType" }
+// { dg-prune-output "signed or unsigned integer" }
// { dg-prune-output "invalid use of incomplete type" }
// { dg-do run { target c++23 } }
#include <mdspan>
+#include <cstdint>
#include <testsuite_hooks.h>
constexpr size_t dyn = std::dynamic_extent;
static_assert(std::is_unsigned_v<std::extents<int, 2>::size_type>);
static_assert(std::is_unsigned_v<std::extents<unsigned int, 2>::size_type>);
-static_assert(std::is_same_v<std::extents<char, 2>::index_type, char>);
static_assert(std::is_same_v<std::extents<int, 2>::index_type, int>);
static_assert(std::is_same_v<std::extents<unsigned int, 2>::index_type,
unsigned int>);
// Check that the static extents don't take up space.
static_assert(sizeof(std::extents<int, 1, dyn>) == sizeof(int));
-static_assert(sizeof(std::extents<char, 1, dyn>) == sizeof(char));
+static_assert(sizeof(std::extents<short, 1, dyn>) == sizeof(short));
template<typename Extents>
class Container
[[no_unique_address]] std::extents<size_t> b0;
};
-static_assert(sizeof(Container<std::extents<char, 1, 2>>) == sizeof(int));
+static_assert(sizeof(Container<std::extents<short, 1, 2>>) == sizeof(int));
static_assert(sizeof(Container<std::extents<size_t, 1, 2>>) == sizeof(int));
// operator=
test_deduction<0>();
test_deduction<1>(1);
test_deduction<2>(1.0, 2.0f);
- test_deduction<3>(int(1), char(2), size_t(3));
+ test_deduction<3>(int(1), short(2), size_t(3));
return true;
}