5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MDSPAN_AXIS_VIEW_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MDSPAN_AXIS_VIEW_HPP_
12#include "arene/base/detail/make_range_from_indexable.hpp"
17#include "arene/base/stdlib_choice/cstddef.hpp"
18#include "arene/base/stdlib_choice/enable_if.hpp"
19#include "arene/base/stdlib_choice/integer_sequence.hpp"
20#include "arene/base/stdlib_choice/integral_constant.hpp"
28namespace axis_view_detail {
35template <
class IndexType>
37 -> arene::base::full_extent_t {
38 return arene::base::full_extent;
47template <
class IndexType>
48constexpr auto select_slice(IndexType index,
std::true_type )
noexcept -> IndexType {
63 noexcept(arene::base::submdspan(mds, select_slice(index, std::integral_constant<
bool, (Positions == Axis)>{})...))
64) ->
decltype(arene::base::submdspan(mds, select_slice(index, std::integral_constant<
bool, (Positions == Axis)>{})...)
66 return arene::base::submdspan(mds, select_slice(index, std::integral_constant<
bool, (Positions == Axis)>{})...);
74template <std::
size_t Axis>
81 template <
class InSpan>
82 constexpr auto operator()(InSpan
const mds)
const
83 noexcept(
noexcept(mds.extent(
static_cast<typename InSpan::rank_type
>(Axis))))
84 ->
decltype(mds.extent(
static_cast<typename InSpan::rank_type
>(Axis))) {
86 static_assert(Axis < InSpan::rank(),
"axis_view: Axis must be less than the mdspan rank");
88 return mds.extent(
static_cast<typename InSpan::rank_type
>(Axis));
98template <std::
size_t Axis>
99class submdspan_axis_fn {
112 constexpr auto operator()(InSpan
const mds, Index index)
const
113 noexcept(
noexcept(axis_view_detail::submdspan_at_axis<Axis>(
115 static_cast<typename InSpan::index_type
>(index),
118 ->
decltype(axis_view_detail::submdspan_at_axis<Axis>(
120 static_cast<typename InSpan::index_type
>(index),
124 return axis_view_detail::submdspan_at_axis<Axis>(
126 static_cast<typename InSpan::index_type
>(index),
134template <std::
size_t Axis>
135constexpr auto range_factory =
136 bind_back(detail::make_range_from_indexable, axis_extent_fn<Axis>{}, submdspan_axis_fn<Axis>{});
140template <std::
size_t Axis>
150 constexpr auto operator()(InSpan mds)
const noexcept(
is_nothrow_invocable_v<
decltype(range_factory<Axis>), InSpan>) {
151 return range_factory<Axis>(mds);
164 constexpr auto operator()(InSpan mds, Index index)
const
191template <std::
size_t Axis>
192extern constexpr auto axis_view = axis_view_detail::axis_view_fn<Axis>{};
Definition accumulate.hpp:37
constexpr bool is_invocable_v
Determine if a functor type is invocable with the specified argument types.
constexpr auto axis_view
Create a range of slices along an mdspan axis.
constexpr bool is_nothrow_invocable_v
Determine if a functor type is no-throw invocable with the specified argument types.
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_constant< false > false_type
An alias for bool_constant<false>
Definition integral_constant.hpp:79
make_integer_sequence< size_t, Size > make_index_sequence
A helper alias template for make_integer_sequence<size_t, Size>
Definition integer_sequence.hpp:224
integer_sequence< size_t, Ints... > index_sequence
A helper alias template for integer_sequence<size_t, Ints>
Definition integer_sequence.hpp:218
::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
bool_constant< true > true_type
An alias for bool_constant<true>
Definition integral_constant.hpp:76