inline constexpr full_extent_t full_extent{};
template<typename _OffsetType, typename _ExtentType, typename _StrideType>
- struct strided_slice {
+ struct strided_slice
+ {
static_assert(__is_standard_integer<_OffsetType>::value
|| __detail::__integral_constant_like<_OffsetType>);
static_assert(__is_standard_integer<_ExtentType>::value
[[no_unique_address]] _Mapping mapping = _Mapping();
size_t offset{};
};
-#endif
+#endif // __glibcxx_submdspan
template<typename _IndexType, size_t... _Extents>
class extents
__fwd_prod(const _Extents& __exts, size_t __begin, size_t __end) noexcept
{
size_t __sta_prod = [__begin, __end] {
- span<const size_t> __sta_exts = __static_extents<_Extents>(__begin, __end);
+ span<const size_t> __sta_exts
+ = __static_extents<_Extents>(__begin, __end);
size_t __ret = 1;
for(auto __ext : __sta_exts)
if (__ext != dynamic_extent)
template<typename _Layout, typename _Mapping>
concept __mapping_of =
- is_same_v<typename _Layout::template mapping<typename _Mapping::extents_type>,
+ is_same_v<typename _Layout::template mapping<
+ typename _Mapping::extents_type>,
_Mapping>;
template<template<size_t> typename _Layout, typename _Mapping>
// A tag type to create internal ctors.
class __internal_ctor
{ };
+
+ template<typename _Mapping>
+ constexpr typename _Mapping::index_type
+ __offset(const _Mapping& __m) noexcept
+ {
+ using _IndexType = typename _Mapping::index_type;
+ constexpr auto __rank = _Mapping::extents_type::rank();
+
+ if constexpr (__standardized_mapping<_Mapping>)
+ return 0;
+ else if (__empty(__m.extents()))
+ return 0;
+ else
+ {
+ auto __impl = [&__m]<size_t... _Counts>(index_sequence<_Counts...>)
+ { return __m(((void) _Counts, _IndexType(0))...); };
+ return __impl(make_index_sequence<__rank>());
+ }
+ }
}
template<typename _Extents>
bool_constant<_Mp::is_always_unique()>::value;
};
- template<typename _Mapping>
- constexpr typename _Mapping::index_type
- __offset(const _Mapping& __m) noexcept
- {
- using _IndexType = typename _Mapping::index_type;
- constexpr auto __rank = _Mapping::extents_type::rank();
-
- if constexpr (__standardized_mapping<_Mapping>)
- return 0;
- else if (__empty(__m.extents()))
- return 0;
- else
- {
- auto __impl = [&__m]<size_t... _Counts>(index_sequence<_Counts...>)
- { return __m(((void) _Counts, _IndexType(0))...); };
- return __impl(make_index_sequence<__rank>());
- }
- }
-
template<typename _Mapping, typename... _Indices>
constexpr typename _Mapping::index_type
__linear_index_strides(const _Mapping& __m, _Indices... __indices)
RValue,
};
-template<CustomIndexKind Kind>
+template<CustomIndexKind Kind, bool Copyable = false>
class CustomIndexType
{
public:
: value(i)
{ }
- CustomIndexType() = delete;
- CustomIndexType(const CustomIndexType&) = delete;
- CustomIndexType(CustomIndexType&&) = delete;
+ CustomIndexType() requires(Copyable) = default;
+ CustomIndexType() requires(!Copyable) = delete;
- const CustomIndexType&
- operator=(const CustomIndexType&) = delete;
+ CustomIndexType(const CustomIndexType&) requires(Copyable) = default;
+ CustomIndexType(const CustomIndexType&) requires(!Copyable) = delete;
- const CustomIndexType&
- operator=(CustomIndexType&&) = delete;
+ CustomIndexType(CustomIndexType&&) requires(Copyable) = default;
+ CustomIndexType(CustomIndexType&&) requires(!Copyable) = delete;
+
+ CustomIndexType&
+ operator=(const CustomIndexType&) requires(Copyable) = default;
+ CustomIndexType&
+ operator=(const CustomIndexType&) requires(!Copyable) = delete;
+
+ CustomIndexType&
+ operator=(CustomIndexType&&) requires(Copyable) = default;
+ CustomIndexType&
+ operator=(CustomIndexType&&) requires(!Copyable) = delete;
constexpr
operator int() const noexcept
-#ifndef TEST_MDSPAN_PADDED_TRAITS_H
-#define TEST_MDSPAN_PADDED_TRAITS_H
+#ifndef TEST_MDSPAN_LAYOUT_TRAITS_H
+#define TEST_MDSPAN_LAYOUT_TRAITS_H
#include <algorithm>
+enum class PaddingSide
+{
+ Left,
+ Right
+};
+
template<typename Layout>
constexpr static bool is_left_padded = false;
is_padded_layout = is_left_padded<Layout> || is_right_padded<Layout>;
#if __cplusplus > 202302L
+template<PaddingSide Side, typename Layout>
+ constexpr bool
+ is_same_padded;
+
+template<typename Layout>
+ constexpr bool
+ is_same_padded<PaddingSide::Left, Layout> = is_left_padded<Layout>;
+
+template<typename Layout>
+ constexpr bool
+ is_same_padded<PaddingSide::Right, Layout> = is_right_padded<Layout>;
+
template<typename Extents>
constexpr auto
dynamic_extents_array(const Extents& exts)
return ret;
}
-enum class PaddingSide
-{
- Left,
- Right
-};
-
struct DeducePaddingSide
{
template<template<size_t> typename Layout>
constexpr static PaddingSide
from_typename()
{
- if constexpr (is_left_padded<Layout>)
+ if constexpr (std::same_as<Layout, std::layout_left>)
+ return PaddingSide::Left;
+ else if constexpr (is_left_padded<Layout>)
return PaddingSide::Left;
else
return PaddingSide::Right;
template<typename T, size_t N>
constexpr static std::array<T, N>
- make_array(const std::array<T, N>& expected)
- { return expected; }
+ make_array(const std::array<T, N>& a)
+ { return a; }
+
+ template<typename... Indices>
+ constexpr static auto
+ make_indices(Indices... indices)
+ { return std::array{indices...}; }
+
+ template<typename... Ts>
+ constexpr static std::tuple<Ts...>
+ make_tuple(const std::tuple<Ts...>& tup)
+ { return tup; }
template<typename Mapping>
constexpr static auto
return a;
}
+ template<typename... Indices>
+ constexpr static auto
+ make_indices(Indices... indices)
+ { return make_array(std::array{indices...}); }
+
+ template<typename... Ts>
+ constexpr static auto
+ make_tuple(const std::tuple<Ts...>& tup)
+ {
+ constexpr size_t rank = sizeof...(Ts);
+ auto impl = [&]<size_t... I>(std::index_sequence<I...>)
+ {
+ auto idx = [rank](size_t i) consteval
+ { return rank - 1 - i; };
+ return std::tuple<Ts...[idx(I)]...>{get<idx(I)>(tup)...};
+ };
+ return impl(std::make_index_sequence<rank>());
+ }
+
template<typename Mapping>
constexpr static auto
padded_stride(const Mapping& m)
// { dg-do run { target c++23 } }
#include <mdspan>
-#include "padded_traits.h"
+#include "../layout_traits.h"
#include <cstdint>
#include <testsuite_hooks.h>
#include <mdspan>
#include "../int_like.h"
-#include "padded_traits.h"
+#include "../layout_traits.h"
#include <cstdint>
#include <testsuite_hooks.h>
#include <cstdint>
#include "../int_like.h"
-#include "padded_traits.h"
+#include "../layout_traits.h"
#include <testsuite_hooks.h>
constexpr size_t dyn = std::dynamic_extent;
// { dg-do compile { target c++26 } }
#include <mdspan>
-#include "padded_traits.h"
+#include "../layout_traits.h"
#include <cstdint>
constexpr size_t dyn = std::dynamic_extent;