7#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MDSPAN_MAKE_MDSPAN_HPP_
8#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MDSPAN_MAKE_MDSPAN_HPP_
14#include "arene/base/detail/dynamic_extent.hpp"
15#include "arene/base/mdspan/detail/deduced_static_extent.hpp"
21#include "arene/base/stdlib_choice/cstddef.hpp"
22#include "arene/base/stdlib_choice/enable_if.hpp"
23#include "arene/base/stdlib_choice/extent.hpp"
24#include "arene/base/stdlib_choice/forward.hpp"
25#include "arene/base/stdlib_choice/is_array.hpp"
26#include "arene/base/stdlib_choice/is_convertible.hpp"
27#include "arene/base/stdlib_choice/is_pointer.hpp"
28#include "arene/base/stdlib_choice/move.hpp"
29#include "arene/base/stdlib_choice/rank.hpp"
30#include "arene/base/stdlib_choice/remove_all_extents.hpp"
31#include "arene/base/stdlib_choice/remove_cv.hpp"
32#include "arene/base/stdlib_choice/remove_pointer.hpp"
33#include "arene/base/stdlib_choice/remove_reference.hpp"
41namespace make_mdspan_detail {
44class make_mdspan_impl {
56 constraints<std::enable_if_t<std::is_array<CArray>::value>, std::enable_if_t<std::rank<CArray>::value == 1>> =
58 constexpr auto operator()(CArray& array)
const noexcept
59 -> mdspan<std::remove_all_extents_t<CArray>, extents<std::size_t, std::extent<CArray, 0>::value>> {
60 return {array, extents<std::size_t, std::extent<CArray, 0>::value>{}};
72 constexpr auto operator()(Pointer&& ptr)
const noexcept
73 -> mdspan<std::remove_pointer_t<std::remove_reference_t<Pointer>>, extents<std::size_t>> {
96 typename... Integrals,
100 constexpr auto operator()(ElementType* ptr, Integrals... extent_values)
const noexcept -> mdspan<
105 extents<std::size_t, mdspan_detail::deduced_static_extent_v<remove_cvref_t<Integrals>>...>{
133 typename ElementType,
134 typename DimensionType,
137 std::enable_if_t<std::is_convertible<DimensionType, std::size_t>::value>,
139 constexpr auto operator()(ElementType* ptr, span<DimensionType, Rank> extent_values)
const noexcept
140 -> mdspan<ElementType, dextents<std::size_t, Rank>> {
160 typename ElementType,
161 typename DimensionType,
163 constraints<std::enable_if_t<std::is_convertible<DimensionType, std::size_t>::value>> =
nullptr>
164 constexpr auto operator()(ElementType* ptr, array<DimensionType, Rank>
const& extent_values)
const noexcept
165 -> mdspan<ElementType, dextents<std::size_t, Rank>> {
180 typename ElementType,
181 typename ExtentsType,
183 constexpr auto operator()(ElementType* ptr, ExtentsType
const& source_extents)
const noexcept
184 -> mdspan<ElementType, ExtentsType> {
185 return {ptr, source_extents};
198 typename ElementType,
199 typename MappingType,
201 constexpr auto operator()(ElementType* ptr, MappingType
const& mapping)
const noexcept
202 -> mdspan<ElementType, typename MappingType::extents_type, typename MappingType::layout_type> {
203 return {ptr, mapping};
220 typename MappingType,
221 typename AccessorType,
225 constexpr auto operator()(
226 typename AccessorType::data_handle_type
const& ptr,
227 MappingType
const& mapping,
228 AccessorType
const& accessor
231 typename AccessorType::element_type,
232 typename MappingType::extents_type,
233 typename MappingType::layout_type,
235 return {ptr, mapping, accessor};
#define ARENE_CPP14_INLINE_VARIABLE(type, name)
Emulates C++17's inline variable declarations for function objects.
Definition cpp14_inline.hpp:69
static constexpr value_type value
Definition integral_constant.hpp:34
Definition accumulate.hpp:37
typename extents_detail::dextents_helper< IndexType, std::integral_constant< std::size_t, Rank > >::type dextents
Backport of std::dextents from C++23, a type representing the extents of a multidimensional array wit...
Definition extents.hpp:407
constexpr bool all_of_v
Trait which tests if every value in a parameter pack is true .
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
remove_cv_t< remove_reference_t< T > > remove_cvref_t
Backport of std::remove_cvref_t.
Definition remove_cvref.hpp:35
Definition accumulate.hpp:36
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
constexpr auto forward(remove_reference_t< T > &value) noexcept -> T &&
Cast a value to an rvalue if T is an rvalue or rvalue reference, otherwise forward an lvalue referenc...
Definition forward.hpp:24
Provides the all_of_v<bool...> trait.