Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy > Class Template Reference

A multidimensional view of elements over a contiguous sequence of elements. More...

Inheritance diagram for arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >:
Inheritance graph

Public Types

using accessor_type = AccessorPolicy
 The accessor policy type.
 
using data_handle_type = typename accessor_type::data_handle_type
 The data handle type.
 
using element_type = ElementType
 The element type.
 
using extents_type = Extents
 The extents type.
 
using index_type = typename extents_type::index_type
 The index type.
 
using layout_type = LayoutPolicy
 The layout policy type.
 
using mapping_type = typename layout_type::template mapping<extents_type>
 The mapping type.
 
using rank_type = typename extents_type::rank_type
 The rank type.
 
using reference = typename accessor_type::reference
 The reference type.
 
using size_type = typename extents_type::size_type
 The size type.
 
using value_type = std::remove_cv_t<element_type>
 The value type.
 

Public Member Functions

template<typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t<(Ext::rank_dynamic() > 0)>, std::enable_if_t< std::is_default_constructible< typename Acc::data_handle_type >::value >, std::enable_if_t< std::is_default_constructible< Map >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value >>
constexpr mdspan () noexcept
 Default constructor.
 
template<class OtherIndexType, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value >, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
constexpr mdspan (data_handle_type handle, array< OtherIndexType, rank_dynamic()> const &extents_in) noexcept
 Construct mdspan with a data handle and extents.
 
template<class OtherIndexType, std::size_t Size, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value >, std::enable_if_t< Size==rank()>, std::enable_if_t< Size !=rank_dynamic()>, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
constexpr mdspan (data_handle_type handle, array< OtherIndexType, Size > const &extents_in) noexcept
 Construct mdspan with a data handle and extents.
 
template<typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_constructible< Map, Ext const & >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
constexpr mdspan (data_handle_type handle, extents_type const &extents_in) noexcept
 Construct mdspan with a data handle and extents.
 
template<typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
constexpr mdspan (data_handle_type handle, mapping_type const &mapping_in) noexcept
 Construct mdspan with a data handle and mapping.
 
constexpr mdspan (data_handle_type handle, mapping_type const &mapping_in, accessor_type const &accessor_in) noexcept
 Construct mdspan with a data handle, mapping, and accessor.
 
template<class... OtherIndexTypes, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< all_of_v< std::is_convertible< OtherIndexTypes, index_type >::value... > >, std::enable_if_t< all_of_v< std::is_nothrow_constructible< index_type, OtherIndexTypes >::value... > >, std::enable_if_t< sizeof...(OtherIndexTypes)==rank()||sizeof...(OtherIndexTypes)==rank_dynamic()>, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
constexpr mdspan (data_handle_type handle, OtherIndexTypes... extents_in) noexcept
 Construct mdspan with a data handle and extents.
 
template<class OtherIndexType, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value >, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
constexpr mdspan (data_handle_type handle, span< OtherIndexType, rank_dynamic()> extents_in) noexcept
 Construct mdspan with a data handle and extents.
 
template<class OtherIndexType, std::size_t Size, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value >, std::enable_if_t< Size==rank()>, std::enable_if_t< Size !=rank_dynamic()>, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
constexpr mdspan (data_handle_type handle, span< OtherIndexType, Size > extents_in) noexcept
 Construct mdspan with a data handle and extents.
 
template<class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherAccessor, constraints< std::enable_if_t< converting_constructor_is_explicit_v< OtherExtents, OtherLayoutPolicy, OtherAccessor > >, std::enable_if_t< std::is_constructible< mapping_type, typename OtherLayoutPolicy::template mapping< OtherExtents > const & >::value >, std::enable_if_t< std::is_constructible< accessor_type, OtherAccessor const & >::value >, std::enable_if_t< std::is_constructible< data_handle_type, typename OtherAccessor::data_handle_type const & >::value >, std::enable_if_t< std::is_constructible< extents_type, OtherExtents const & >::value > > = nullptr>
constexpr mdspan (mdspan< OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessor > const &other)
 Converting constructor from another mdspan.
 
template<class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherAccessor, constraints< std::enable_if_t<!converting_constructor_is_explicit_v< OtherExtents, OtherLayoutPolicy, OtherAccessor > >, std::enable_if_t< std::is_constructible< mapping_type, typename OtherLayoutPolicy::template mapping< OtherExtents > const & >::value >, std::enable_if_t< std::is_constructible< accessor_type, OtherAccessor const & >::value >, std::enable_if_t< std::is_constructible< data_handle_type, typename OtherAccessor::data_handle_type const & >::value >, std::enable_if_t< std::is_constructible< extents_type, OtherExtents const & >::value > > = nullptr>
constexpr mdspan (mdspan< OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessor > const &other)
 Converting constructor from another mdspan.
 
constexpr auto accessor () const noexcept -> accessor_type const &
 Get the accessor.
 
constexpr auto data_handle () const noexcept -> data_handle_type const &
 Get the data handle.
 
constexpr auto empty () const noexcept -> bool
 Check if the size is zero.
 
constexpr auto extent (rank_type dimension) const noexcept -> index_type
 Get the actual extent for the given dimension, returning the extent supplied to the constructor for dynamic extents.
 
constexpr auto mapping () const noexcept -> mapping_type const &
 Get the mapping.
 
template<class OtherIndexType, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value > > = nullptr>
constexpr auto operator() (array< OtherIndexType, extents_type::rank > const &indices) const noexcept(arene::base::is_nothrow_invocable_v<, mdspan const &, array< OtherIndexType, extents_type::rank()> const & >) -> reference
 Access an element with an array of indices.
 
template<class... OtherIndexTypes, constraints< std::enable_if_t< std::is_convertible< OtherIndexTypes, index_type >::value >..., std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexTypes >::value >..., std::enable_if_t< sizeof...(OtherIndexTypes)==extents_type::rank > > = nullptr>
constexpr auto operator() (OtherIndexTypes... indices) const noexcept(arene::base::is_nothrow_invocable_v< mapping_type const &, OtherIndexTypes &&... > &&noexcept(std::declval< accessor_type const & >().access(//std::declval< data_handle_type const & >(),//std::declval< std::size_t >()))) -> reference
 Access an element at the specified multi-dimensional index.
 
template<class OtherIndexType, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value > > = nullptr>
constexpr auto operator() (span< OtherIndexType, extents_type::rank > const indices) const noexcept(arene::base::is_nothrow_invocable_v<, mdspan const &, mdspan_detail::tuple_span< OtherIndexType, extents_type::rank > const & >) -> reference
 Access an mdspan element with a span of indices.
 
constexpr auto size () const noexcept -> size_type
 Get the size of the multidimensional index space.
 

Static Public Member Functions

static constexpr auto static_extent (rank_type dimension) noexcept -> std::size_t
 Get the static extent for the given dimension.
 

Static Public Attributes

static constexpr std::integral_constant< rank_type, Extents::rank()> rank {}
 Get the number of dimensions.
 
static constexpr std::integral_constant< rank_type, Extents::rank_dynamic()> rank_dynamic {}
 Get the number of dimensions with dynamic extent.
 

Friends

constexpr auto swap (mdspan &lhs, mdspan &rhs) noexcept -> void
 swaps the contents
 

Detailed Description

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
class arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >

A multidimensional view of elements over a contiguous sequence of elements.

Template Parameters
ElementTypethe element type
Extentsan instantiation of extents representing the shape of the multidimensional index space
LayoutPolicya layout policy (defaults to layout_right)
AccessorPolicyan accessor policy (defaults to default_accessor<ElementType>)

Backport of std::mdspan from C++23. The mdspan class template is a multidimensional array view that maps a multidimensional index to an element of the array. The mapping and element access policies are configurable, and the underlying array need not be contiguous or even exist in memory at all.

Member Typedef Documentation

◆ accessor_type

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::accessor_type = AccessorPolicy

The accessor policy type.

◆ data_handle_type

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::data_handle_type = typename accessor_type::data_handle_type

The data handle type.

◆ element_type

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::element_type = ElementType

The element type.

◆ extents_type

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::extents_type = Extents

The extents type.

◆ index_type

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::index_type = typename extents_type::index_type

The index type.

◆ layout_type

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::layout_type = LayoutPolicy

The layout policy type.

◆ mapping_type

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mapping_type = typename layout_type::template mapping<extents_type>

The mapping type.

◆ rank_type

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::rank_type = typename extents_type::rank_type

The rank type.

◆ reference

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::reference = typename accessor_type::reference

The reference type.

◆ size_type

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::size_type = typename extents_type::size_type

The size type.

◆ value_type

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::value_type = std::remove_cv_t<element_type>

The value type.

Constructor & Destructor Documentation

◆ mdspan() [1/11]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t<(Ext::rank_dynamic() > 0)>, std::enable_if_t< std::is_default_constructible< typename Acc::data_handle_type >::value >, std::enable_if_t< std::is_default_constructible< Map >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value >>
arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mdspan ( )
inlineconstexprnoexcept

Default constructor.

Precondition
[0, mapping().required_span_size()) is an accessible range of data_handle() and accessor() for the values of mapping() and accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.
Note
This constructor has no visible effect and creates an mdspan with all dynamic extents equal to zero. This implies that a default constructed span covers no elements.

◆ mdspan() [2/11]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<class... OtherIndexTypes, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< all_of_v< std::is_convertible< OtherIndexTypes, index_type >::value... > >, std::enable_if_t< all_of_v< std::is_nothrow_constructible< index_type, OtherIndexTypes >::value... > >, std::enable_if_t< sizeof...(OtherIndexTypes)==rank()||sizeof...(OtherIndexTypes)==rank_dynamic()>, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mdspan ( data_handle_type handle,
OtherIndexTypes... extents_in )
inlineexplicitconstexprnoexcept

Construct mdspan with a data handle and extents.

Template Parameters
OtherIndexTypesThe types of the extents used to initialize the layout mapping
Parameters
handleA user supplied data handle
extents_inUser supplied extents

Construct an mdspan initialized with a user supplied data_handle_type, a variadic list of extents which are converted to extents_type and used to initialize the layout mapping, and a default constructed accessor_type.

Precondition
[0, mapping().required_span_size()) is an accessible range of handle and accessor() for the values of mapping() and accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.

◆ mdspan() [3/11]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<class OtherIndexType, std::size_t Size, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value >, std::enable_if_t< Size==rank()>, std::enable_if_t< Size !=rank_dynamic()>, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mdspan ( data_handle_type handle,
span< OtherIndexType, Size > extents_in )
inlineexplicitconstexprnoexcept

Construct mdspan with a data handle and extents.

Template Parameters
OtherIndexTypeThe type of the extent values used to initialize the layout mapping
Parameters
handleA user supplied data handle
extents_inUser supplied extents

Construct an mdspan initialized with a user supplied data_handle_type, a span of extents which are converted to extents_type and used to initialize the layout mapping, and a default constructed accessor_type.

Precondition
[0, mapping().required_span_size()) is an accessible range of handle and accessor() for the values of mapping() and accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.
Note
This constructor is explicit only if N != rank_dynamic() .

◆ mdspan() [4/11]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<class OtherIndexType, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value >, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mdspan ( data_handle_type handle,
span< OtherIndexType, rank_dynamic()> extents_in )
inlineconstexprnoexcept

Construct mdspan with a data handle and extents.

Template Parameters
OtherIndexTypeThe type of the extent values used to initialize the layout mapping
Parameters
handleA user supplied data handle
extents_inUser supplied extents

Construct an mdspan initialized with a user supplied data_handle_type, a span of extents which are converted to extents_type and used to initialize the layout mapping, and a default constructed accessor_type.

Precondition
[0, mapping().required_span_size()) is an accessible range of handle and accessor() for the values of mapping() and accessor after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.
Note
This constructor is explicit only if N != rank_dynamic() .

◆ mdspan() [5/11]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<class OtherIndexType, std::size_t Size, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value >, std::enable_if_t< Size==rank()>, std::enable_if_t< Size !=rank_dynamic()>, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mdspan ( data_handle_type handle,
array< OtherIndexType, Size > const & extents_in )
inlineexplicitconstexprnoexcept

Construct mdspan with a data handle and extents.

Template Parameters
OtherIndexTypeThe type of the extent values used to initialize the layout mapping
Parameters
handleA user supplied data handle
extents_inUser supplied extents

Construct an mdspan initialized with a user supplied data_handle_type, an array of extents which are converted to extents_type and used to initialize the layout mapping, and a default constructed accessor_type.

Precondition
[0, mapping().required_span_size()) is an accessible range of handle and accessor() for the values of mapping() and accessor after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.
Note
This constructor is explicit only if N != rank_dynamic() .

◆ mdspan() [6/11]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<class OtherIndexType, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value >, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mdspan ( data_handle_type handle,
array< OtherIndexType, rank_dynamic()> const & extents_in )
inlineconstexprnoexcept

Construct mdspan with a data handle and extents.

Template Parameters
OtherIndexTypeThe type of the extent values used to initialize the layout mapping
Parameters
handleA user supplied data handle
extents_inUser supplied extents

Construct an mdspan initialized with a user supplied data_handle_type, an array of extents which are converted to extents_type and used to initialize the layout mapping, and a default constructed accessor_type.

Precondition
[0, mapping().required_span_size()) is an accessible range of handle and accessor() for the values of mapping() and accessor after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.
Note
This constructor is explicit only if N != rank_dynamic() .

◆ mdspan() [7/11]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_constructible< Map, Ext const & >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mdspan ( data_handle_type handle,
extents_type const & extents_in )
inlineconstexprnoexcept

Construct mdspan with a data handle and extents.

Parameters
handleA user supplied data handle
extents_inUser supplied extents
Precondition
[0, mapping().required_span_size()) is an accessible range of handle and accessor() for the values of mapping() and accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.

Construct an mdspan initialized with a user supplied data_handle_type, a user supplied extents_type used to initialize the layout mapping, and a default constructed accessor_type.

◆ mdspan() [8/11]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr>
arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mdspan ( data_handle_type handle,
mapping_type const & mapping_in )
inlineconstexprnoexcept

Construct mdspan with a data handle and mapping.

Parameters
handleA user supplied data handle
mapping_inUser supplied mapping
Precondition
[0, mapping_in.required_span_size()) is an accessible range of handle and accessor() for the value of accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.

Construct an mdspan initialized with a user supplied data_handle_type, a user supplied mapping, and a default constructed accessor_type.

◆ mdspan() [9/11]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mdspan ( data_handle_type handle,
mapping_type const & mapping_in,
accessor_type const & accessor_in )
inlineconstexprnoexcept

Construct mdspan with a data handle, mapping, and accessor.

Parameters
handleA user supplied data handle
mapping_inUser supplied mapping
accessor_inUser supplied accessor
Precondition
[0, mapping_in.required_span_size()) is an accessible range of handle and accessor_in. This precondition is not checked, but violating it is undefined behavior.

Construct an mdspan initialized with a user supplied data_handle_type, a user supplied mapping, and a user supplied accessor_type.

◆ mdspan() [10/11]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherAccessor, constraints< std::enable_if_t< converting_constructor_is_explicit_v< OtherExtents, OtherLayoutPolicy, OtherAccessor > >, std::enable_if_t< std::is_constructible< mapping_type, typename OtherLayoutPolicy::template mapping< OtherExtents > const & >::value >, std::enable_if_t< std::is_constructible< accessor_type, OtherAccessor const & >::value >, std::enable_if_t< std::is_constructible< data_handle_type, typename OtherAccessor::data_handle_type const & >::value >, std::enable_if_t< std::is_constructible< extents_type, OtherExtents const & >::value > > = nullptr>
arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mdspan ( mdspan< OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessor > const & other)
inlineexplicitconstexpr

Converting constructor from another mdspan.

Template Parameters
OtherElementTypeThe element type of the other mdspan
OtherExtentsThe extents type of the other mdspan
OtherLayoutPolicyThe layout policy of the other mdspan
OtherAccessorThe accessor policy of the other mdspan
Parameters
otherThe other mdspan to construct from
Precondition
For each rank index r of extents_type, static_extent(r) == dynamic_extent || static_extent(r) == other.extent(r) is true, otherwise this is an ARENE_PRECONDITION violation.
[0, mapping().required_span_size()) is an accessible range of handle() and accessor() for values of handle(), mapping(), and accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.
Note
This constructor is explicit only if !std::is_convertible<typename OtherLayoutPolicy::template mapping<OtherExtents> const&, mapping_type>::value || !std::is_convertible<OtherAccessor const&, accessor_type>::value;

◆ mdspan() [11/11]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherAccessor, constraints< std::enable_if_t<!converting_constructor_is_explicit_v< OtherExtents, OtherLayoutPolicy, OtherAccessor > >, std::enable_if_t< std::is_constructible< mapping_type, typename OtherLayoutPolicy::template mapping< OtherExtents > const & >::value >, std::enable_if_t< std::is_constructible< accessor_type, OtherAccessor const & >::value >, std::enable_if_t< std::is_constructible< data_handle_type, typename OtherAccessor::data_handle_type const & >::value >, std::enable_if_t< std::is_constructible< extents_type, OtherExtents const & >::value > > = nullptr>
arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mdspan ( mdspan< OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessor > const & other)
inlineconstexpr

Converting constructor from another mdspan.

Template Parameters
OtherElementTypeThe element type of the other mdspan
OtherExtentsThe extents type of the other mdspan
OtherLayoutPolicyThe layout policy of the other mdspan
OtherAccessorThe accessor policy of the other mdspan
Parameters
otherThe other mdspan to construct from
Precondition
For each rank index r of extents_type, static_extent(r) == dynamic_extent || static_extent(r) == other.extent(r) is true, otherwise this is an ARENE_PRECONDITION violation.
[0, mapping().required_span_size()) is an accessible range of handle() and accessor() for values of handle(), mapping(), and accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.
Note
This constructor is explicit only if !std::is_convertible<typename OtherLayoutPolicy::template mapping<OtherExtents> const&, mapping_type>::value || !std::is_convertible<OtherAccessor const&, accessor_type>::value;

Member Function Documentation

◆ accessor()

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
auto arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::accessor ( ) const -> accessor_type const&
inlineconstexprnoexcept

Get the accessor.

Returns
A reference to the accessor object

◆ data_handle()

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
auto arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::data_handle ( ) const -> data_handle_type const&
inlineconstexprnoexcept

Get the data handle.

Returns
The data handle

◆ empty()

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
auto arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::empty ( ) const -> bool
inlineconstexprnoexcept

Check if the size is zero.

Returns
true if the size is zero, false otherwise

◆ extent()

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
auto arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::extent ( rank_type dimension) const -> index_type
inlineconstexprnoexcept

Get the actual extent for the given dimension, returning the extent supplied to the constructor for dynamic extents.

Parameters
dimensionThe index of the dimension for which to get the extent
Returns
The extent of the specified dimension

◆ mapping()

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
auto arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mapping ( ) const -> mapping_type const&
inlineconstexprnoexcept

Get the mapping.

Returns
A reference to the mapping object

◆ operator()() [1/3]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<class OtherIndexType, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value > > = nullptr>
auto arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::operator() ( array< OtherIndexType, extents_type::rank > const & indices) const -> reference
inlineconstexprnoexcept

Access an element with an array of indices.

Template Parameters
OtherIndexTypeIndex type contained by the array
Parameters
indicesThe multi-dimensional index as an array
Returns
reference to the indices-th element of the mdspan

◆ operator()() [2/3]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<class... OtherIndexTypes, constraints< std::enable_if_t< std::is_convertible< OtherIndexTypes, index_type >::value >..., std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexTypes >::value >..., std::enable_if_t< sizeof...(OtherIndexTypes)==extents_type::rank > > = nullptr>
auto arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::operator() ( OtherIndexTypes... indices) const -> reference
inlineconstexprnoexcept

Access an element at the specified multi-dimensional index.

Template Parameters
OtherIndexTypesNon-type template parameter pack of indices
Parameters
indicesThe multi-dimensional index as a variadic
Returns
reference to the indices-th element of the mdspan

◆ operator()() [3/3]

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
template<class OtherIndexType, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value > > = nullptr>
auto arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::operator() ( span< OtherIndexType, extents_type::rank > const indices) const -> reference
inlineconstexprnoexcept

Access an mdspan element with a span of indices.

Template Parameters
OtherIndexTypeIndex type contained by the span
Parameters
indicesThe multi-dimensional index as an span
Returns
reference to the indices-th element of the mdspan

◆ size()

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
auto arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::size ( ) const -> size_type
inlineconstexprnoexcept

Get the size of the multidimensional index space.

Returns
The size of the multidimensional index space

◆ static_extent()

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
static constexpr auto arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::static_extent ( rank_type dimension) -> std::size_t
inlinestaticconstexprnoexcept

Get the static extent for the given dimension.

Parameters
dimensionThe index of the dimension for which to get the static extent
Returns
The value from Extents for the specified dimension

Friends And Related Symbol Documentation

◆ swap

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
auto swap ( mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy > & lhs,
mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy > & rhs ) -> void
friend

swaps the contents

Parameters
lhsleft mdspan value to swap
rhsright mdspan value to swap

Member Data Documentation

◆ rank

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
std::integral_constant<rank_type, Extents::rank()> arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::rank {}
staticconstexpr

Get the number of dimensions.

Returns
The rank of the mdspan

◆ rank_dynamic

template<typename ElementType, typename Extents, typename LayoutPolicy = layout_right, typename AccessorPolicy = default_accessor<ElementType>>
std::integral_constant<rank_type, Extents::rank_dynamic()> arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::rank_dynamic {}
staticconstexpr

Get the number of dimensions with dynamic extent.

Returns
The dynamic rank of the mdspan

The documentation for this class was generated from the following file: