7#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MDSPAN_SUBMDSPAN_CANONICALIZE_SLICES_HPP_
8#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MDSPAN_SUBMDSPAN_CANONICALIZE_SLICES_HPP_
14#include "arene/base/mdspan/detail/canonical_slice.hpp"
15#include "arene/base/mdspan/detail/is_valid_submdspan_slice_for.hpp"
16#include "arene/base/mdspan/detail/mandate_each_argtype_is_submdspan_slice.hpp"
17#include "arene/base/mdspan/detail/mandate_each_argtype_is_valid_submdspan_slice_type_for.hpp"
18#include "arene/base/mdspan/detail/to_array.hpp"
20#include "arene/base/stdlib_choice/cstddef.hpp"
21#include "arene/base/stdlib_choice/enable_if.hpp"
22#include "arene/base/stdlib_choice/ignore.hpp"
23#include "arene/base/stdlib_choice/logical_and.hpp"
24#include "arene/base/stdlib_choice/move.hpp"
25#include "arene/base/stdlib_choice/tuple.hpp"
27#include "arene/base/tuple/detail/tuple_transform_reduce.hpp"
28#include "arene/base/tuple/detail/tuple_zip.hpp"
39namespace submdspan_canonicalize_slices_detail {
43class submdspan_canonicalize_slices_fn {
77 class... SliceSpecifiers,
79 std::nullptr_t = mdspan_detail::mandate_each_argtype_is_submdspan_slice<IndexType, SliceSpecifiers...>()>
80 constexpr auto operator()(extents<IndexType, Extents...>
const& src, SliceSpecifiers... slices)
const noexcept(
83 std::tuple<mdspan_detail::canonical_slice_t<IndexType, SliceSpecifiers>...>
86 std::ignore = mdspan_detail::mandate_each_argtype_is_valid_submdspan_slice_type_for<IndexType, Extents...>(
87 type_list<SliceSpecifiers...>{}
90 auto const canonicalized = std::tuple<mdspan_detail::canonical_slice_t<IndexType, SliceSpecifiers>...>{
91 mdspan_detail::canonical_slice<IndexType>(
std::move(slices))...
96 using slice_refs = std::tuple<mdspan_detail::canonical_slice_t<IndexType, SliceSpecifiers>
const&...>;
99 slice_refs refs{canonicalized};
100 auto zipped = tuple_detail::tuple_zip(refs, mdspan_detail::to_array(src));
101 auto validate_slice = arene::base::bind_front(apply, mdspan_detail::is_valid_submdspan_slice_for);
104 tuple_detail::tuple_transform_reduce(
std::move(zipped),
true, std::logical_and<>{},
std::move(validate_slice))
107 return canonicalized;
124 submdspan_canonicalize_slices_detail::submdspan_canonicalize_slices_fn,
125 submdspan_canonicalize_slices
#define ARENE_CPP14_INLINE_VARIABLE(type, name)
Emulates C++17's inline variable declarations for function objects.
Definition cpp14_inline.hpp:69
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
Definition accumulate.hpp:37
constexpr bool all_of_v
Trait which tests if every value in a parameter pack is true .
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
typedef nullptr_t
The type of nullptr.
Definition cstddef.hpp:33
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
::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
static constexpr auto const & ignore
An object to which anything can be assigned, which ignores the assigned value.
Definition ignore.hpp:72
Provides the all_of_v<bool...> trait.