5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MDSPAN_IS_SLICEABLE_MAPPING_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MDSPAN_IS_SLICEABLE_MAPPING_HPP_
10#include "arene/base/mdspan/detail/count.hpp"
11#include "arene/base/mdspan/detail/do_submdspan_mapping.hpp"
12#include "arene/base/mdspan/detail/non_collapsing_slice_type.hpp"
17#include "arene/base/stdlib_choice/cstddef.hpp"
18#include "arene/base/stdlib_choice/enable_if.hpp"
19#include "arene/base/stdlib_choice/is_same.hpp"
27namespace is_sliceable_mapping_detail {
30struct invalid_slice {};
37template <
typename SubmdspanMappingResult,
class ExpectedIndexType, std::
size_t ExpectedRank>
38extern constexpr bool is_valid_submdspan_mapping_result =
false;
42template <
class... Slices>
43constexpr auto non_collapsing_slice_mask =
44 arene::base::array<
bool,
sizeof...(Slices)>{arene::base::mdspan_detail::non_collapsing_slice_type_v<Slices>...};
48template <
class SlicesTypeList>
49extern constexpr std::size_t non_collapsing_slice_count = 0U;
53template <
class... Slices>
54extern constexpr std::size_t non_collapsing_slice_count<arene::base::type_list<Slices...>> =
static_cast<std::size_t>(
55 mdspan_detail::count(non_collapsing_slice_mask<Slices...>.
begin(), non_collapsing_slice_mask<Slices...>.
end(),
true)
65template <
typename LayoutMapping,
class ExpectedIndexType, std::
size_t ExpectedRank>
66extern constexpr bool is_valid_submdspan_mapping_result<
67 submdspan_mapping_result<LayoutMapping>,
71 (LayoutMapping::extents_type::rank() == ExpectedRank) &&
78template <
class M,
class = constra
ints<>>
79extern constexpr bool is_sliceable_mapping_v =
false;
88extern constexpr bool is_sliceable_mapping_v<
93 (M::extents_type::rank() == 0) ==
95 is_invocable<
decltype(mdspan_detail::do_submdspan_mapping), M>,
96 repeat_type_t<M::extents_type::rank(), type_list, invalid_slice>>::value>,
98 is_invocable<
decltype(mdspan_detail::do_submdspan_mapping), M>,
99 repeat_type_t<M::extents_type::rank(), type_list, full_extent_t>>::value>,
101 is_invocable<
decltype(mdspan_detail::do_submdspan_mapping), M>,
102 repeat_type_t<M::extents_type::rank(), type_list,
typename M::extents_type::index_type>>::value>>> =
103 is_valid_submdspan_mapping_result<
105 invoke_result<
decltype(mdspan_detail::do_submdspan_mapping), M>,
106 repeat_type_t<M::extents_type::rank(), type_list, full_extent_t>>::type,
107 typename M::extents_type::index_type,
108 non_collapsing_slice_count<
repeat_type_t<M::extents_type::rank(), type_list, full_extent_t>>> &&
109 is_valid_submdspan_mapping_result<
111 invoke_result<
decltype(mdspan_detail::do_submdspan_mapping), M>,
112 repeat_type_t<M::extents_type::rank(), type_list,
typename M::extents_type::index_type>>::type,
113 typename M::extents_type::index_type,
114 non_collapsing_slice_count<
115 repeat_type_t<M::extents_type::rank(), type_list,
typename M::extents_type::index_type>>>;
162template <
class M,
class Enable =
void>
static constexpr value_type value
Definition integral_constant.hpp:34
typename concat< Ln... >::type concat_t
collapse L0<T...>, .. Ln<U...> into TypeList<T..., .., U...>
Definition concat.hpp:107
Definition accumulate.hpp:37
constexpr bool is_layout_mapping_v
Helper trait to indicate if the given type has all the basic properties required of a layout mapping:
typename repeat_type< N, T, Arg >::type repeat_type_t
Repeat a template argument a specified number of times.
Definition repeat_type.hpp:48
constexpr bool is_extents_v
Helper variable to check if a provided type is an instantiation of extents.
constexpr bool is_sliceable_mapping_v
Check if a type meets the sliceable layout mapping requirements.
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
Definition accumulate.hpp:36
bool
Check if element Idx and all subsequent elements of the two tuples are equal.
Definition tuple.hpp:649
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
constexpr auto end(Element(&array)[Size]) noexcept -> Element *
Obtain a pointer to the one-past-the-end element of the array.
Definition end.hpp:28
constexpr auto begin(Element(&array)[Size]) noexcept -> Element *
Obtain a pointer to the first element of the array.
Definition begin.hpp:28