7#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MDSPAN_MAKE_MDSPAN_HPP_
8#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MDSPAN_MAKE_MDSPAN_HPP_
11#include "arene/base/array/array.hpp"
12#include "arene/base/compiler_support/cpp14_inline.hpp"
13#include "arene/base/constraints/constraints.hpp"
14#include "arene/base/detail/dynamic_extent.hpp"
15#include "arene/base/mdspan/detail/deduced_static_extent.hpp"
16#include "arene/base/mdspan/extents.hpp"
17#include "arene/base/mdspan/is_accessor_policy.hpp"
18#include "arene/base/mdspan/is_layout_mapping.hpp"
19#include "arene/base/mdspan/mdspan.hpp"
20#include "arene/base/span/span.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"
34#include "arene/base/type_traits/all_of.hpp"
35#include "arene/base/type_traits/remove_cvref.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>{}};
71 constraints<std::enable_if_t<std::is_pointer<std::remove_reference_t<Pointer>>::value>> =
nullptr>
72 constexpr auto operator()(Pointer&& ptr)
const noexcept
73 -> mdspan<std::remove_pointer_t<std::remove_reference_t<Pointer>>, extents<std::size_t>> {
74 return {std::forward<Pointer>(ptr), extents<std::size_t>{}};
92 typename... Integrals,
94 std::enable_if_t<
sizeof...(Integrals) != 0>,
95 std::enable_if_t<all_of_v<std::is_convertible<Integrals, std::size_t>::value...>>> =
nullptr>
96 constexpr auto operator()(ElementType* ptr, Integrals... extent_values)
const noexcept -> mdspan<
98 extents<std::size_t, mdspan_detail::deduced_static_extent_v<remove_cvref_t<Integrals>>...>> {
101 extents<std::size_t, mdspan_detail::deduced_static_extent_v<remove_cvref_t<Integrals>>...>{
102 std::move(extent_values)...
125 typename ElementType,
126 typename DimensionType,
129 std::enable_if_t<std::is_convertible<DimensionType, std::size_t>::value>,
130 std::enable_if_t<Rank != dynamic_extent>> =
nullptr>
131 constexpr auto operator()(ElementType* ptr, span<DimensionType, Rank> extent_values)
const noexcept
132 -> mdspan<ElementType, dextents<std::size_t, Rank>> {
133 return {ptr, dextents<std::size_t, Rank>{extent_values}};
152 typename ElementType,
153 typename DimensionType,
155 constraints<std::enable_if_t<std::is_convertible<DimensionType, std::size_t>::value>> =
nullptr>
156 constexpr auto operator()(ElementType* ptr, array<DimensionType, Rank>
const& extent_values)
const noexcept
157 -> mdspan<ElementType, dextents<std::size_t, Rank>> {
158 return {ptr, dextents<std::size_t, Rank>{extent_values}};
172 typename ElementType,
173 typename ExtentsType,
174 constraints<std::enable_if_t<is_extents_v<ExtentsType>>> =
nullptr>
175 constexpr auto operator()(ElementType* ptr, ExtentsType
const& source_extents)
const noexcept
176 -> mdspan<ElementType, ExtentsType> {
177 return {ptr, source_extents};
190 typename ElementType,
191 typename MappingType,
192 constraints<std::enable_if_t<is_layout_mapping_v<MappingType>>> =
nullptr>
193 constexpr auto operator()(ElementType* ptr, MappingType
const& mapping)
const noexcept
194 -> mdspan<ElementType,
typename MappingType::extents_type,
typename MappingType::layout_type> {
195 return {ptr, mapping};
212 typename MappingType,
213 typename AccessorType,
215 std::enable_if_t<is_layout_mapping_v<MappingType>>,
216 std::enable_if_t<is_accessor_policy_v<AccessorType>>> =
nullptr>
217 constexpr auto operator()(
218 typename AccessorType::data_handle_type
const& ptr,
219 MappingType
const& mapping,
220 AccessorType
const& accessor
223 typename AccessorType::element_type,
224 typename MappingType::extents_type,
225 typename MappingType::layout_type,
227 return {ptr, mapping, accessor};
Definition array_exceptions_disabled.cpp:11
ARENE_CPP14_INLINE_VARIABLE(make_mdspan_detail::make_mdspan_impl, make_mdspan)
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10