[mdspan.sub.map] (original) (raw)
23 Containers library [containers]
23.7 Views [views]
23.7.3 Multidimensional access [views.multidim]
23.7.3.7 submdspan [mdspan.sub]
23.7.3.7.6 Specializations of submdspan_mapping [mdspan.sub.map]
23.7.3.7.6.1 Common [mdspan.sub.map.common]
The following elements apply to all functions in [mdspan.sub.map].
Constraints: sizeof...(slices) equals extents_type::rank().
Mandates: For each rank index k of extents(), exactly one of the following is true:
- models convertible_to<index_type>,
- models index-pair-like<index_type>,
- is_convertible_v<, full_extent_t> is true, or
- is a specialization of strided_slice.
Preconditions: For each rank index k of extents(), all of the following are true:
- if is a specialization of strided_slice,.extent is equal to zero or.stride is greater than zero; and
- 0 ≤ first_<index_type, k>(slices...)
0 ≤ last_<k>(extents(), slices...)
0 ≤ extents().extent(k)
Let sub_ext be the result of submdspan_extents(extents(), slices...) and let SubExtents be decltype(sub_ext).
Let sub_strides be an array<SubExtents::index_type, SubExtents::rank()>such that for each rank index k of extents()for which _map-rank_[k] is not dynamic_extent,sub_strides[_map-rank_[k]] equals:
- stride(k) * de-ice(.stride)if is a specialization of strided_slice and.stride < .extent is true;
- otherwise, stride(k).
Let P be a parameter pack such that is_same_v<make_index_sequence<rank()>, index_sequence<P...>>is true.
If first_<index_type, k>(slices...)equals extents().extent(k)for any rank index k of extents(), then let offset be a value of type size_t equal to(*this).required_span_size().
Otherwise, let offset be a value of type size_t equal to(*this)(first_<index_type, P>(slices...)...).
Given a layout mapping type M, a type S is aunit-stride slice for M if
- S is a specialization of strided_slicewhere S::stride_type models integral-constant-likeand S::stride_type::value equals 1,
- S models index-pair-like<M::index_type>, or
- is_convertible_v<S, full_extent_t> is true.
23.7.3.7.6.2 layout_left specialization of submdspan_mapping [mdspan.sub.map.left]
template<class Extents> template<class... SliceSpecifiers> constexpr auto layout_left::mapping<Extents>::_submdspan-mapping-impl_( SliceSpecifiers... slices) const -> _see below_;
Returns:
- submdspan_mapping_result{*this, 0}, if Extents::rank() == 0 is true;
- otherwise,submdspan_mapping_result{layout_left::mapping(sub_ext), offset}, if SubExtents::rank() == 0 is true;
- otherwise,submdspan_mapping_result{layout_left::mapping(sub_ext), offset}, if
- for each k in the range [0, SubExtents::rank() - 1)),is_convertible_v<, full_extent_t> is true; and
- for k equal to SubExtents::rank() - 1, is a unit-stride slice for mapping;
[Note 1:
If the above conditions are true, all with k larger than SubExtents::rank() - 1are convertible to index_type.
— _end note_]
- otherwise,submdspan_mapping_result{layout_left_padded<S_static>::mapping(sub_ext, stride(u + 1)), offset} if for a value u for which is the smallest value p larger than zero for which is a unit-stride slice for mapping, the following conditions are met:
- is a unit-stride slice for mapping; and
- for each k in the range [u + 1, u + SubExtents::rank() - 1),is_convertible_v<, full_extent_t> is true; and
- for k equal to u + SubExtents::rank() - 1, is a unit-stride slice for mapping;
and where S_static is: - dynamic_extent, if static_extent(k) is dynamic_extentfor any k in the range [0, u + 1),
- otherwise, the product of all valuesstatic_extent(k) for k in the range [0, u + 1);
- otherwise,submdspan_mapping_result{layout_stride::mapping(sub_ext, sub_strides), offset}
23.7.3.7.6.3 layout_right specialization of submdspan_mapping [mdspan.sub.map.right]
template<class Extents> template<class... SliceSpecifiers> constexpr auto layout_right::mapping<Extents>::_submdspan-mapping-impl_( SliceSpecifiers... slices) const -> _see below_;
Returns:
- submdspan_mapping_result{*this, 0}, if Extents::rank() == 0 is true;
- otherwise,submdspan_mapping_result{layout_right::mapping(sub_ext), offset}, if SubExtents::rank() == 0 is true;
- otherwise,submdspan_mapping_result{layout_left::mapping(sub_ext), offset}, if
- otherwise,submdspan_mapping_result{layout_right_padded<S_static>::mapping(sub_ext, stride(rank_ - u - 2)), offset} if for a value u for which is the largest value p smaller than rank_ - 1for which is a unit-stride slice for mapping, the following conditions are met:
- for k equal to rank_ - 1, is a unit-stride slice for mapping; and
- for each k in the range [rank_ - SubExtents::rank() - u + 1, rank_ - u - 1),is_convertible_v<, full_extent_t> is true; and
- for k equal to rank_ - SubExtents::rank() - u,
is a unit-stride slice for mapping;
and where S_static is: - dynamic_extent, if static_extent(k) is dynamic_extentfor any k in the range [rank_ - u - 1, rank_),
- otherwise, the product of all valuesstatic_extent(k)for k in the range [rank_ - u - 1, rank_);
- otherwise,submdspan_mapping_result{layout_stride::mapping(sub_ext, sub_strides), offset}
23.7.3.7.6.4 layout_stride specialization of submdspan_mapping [mdspan.sub.map.stride]
template<class Extents> template<class... SliceSpecifiers> constexpr auto layout_stride::mapping<Extents>::_submdspan-mapping-impl_( SliceSpecifiers... slices) const -> _see below_;
Returns:
- submdspan_mapping_result{*this, 0}, if Extents::rank() == 0 is true;
- otherwise,submdspan_mapping_result{layout_stride::mapping(sub_ext, sub_strides), offset}
23.7.3.7.6.5 layout_left_padded specialization of submdspan_mapping [mdspan.sub.map.leftpad]
template<class Extents> template<class... SliceSpecifiers> constexpr auto layout_left_padded::mapping<Extents>::_submdspan-mapping-impl_( SliceSpecifiers... slices) const -> _see below_;
Returns:
- submdspan_mapping_result{*this, 0}, if Extents::rank() == 0 is true;
- otherwise,submdspan_mapping_result{layout_left::mapping(sub_ext), offset}, if rank_ == 1 is true orSubExtents::rank() == 0 is true;
- otherwise,submdspan_mapping_result{layout_left::mapping(sub_ext), offset}, if
- SubExtents::rank() == 1 is true and
- is a unit-stride slice for mapping;
- otherwise,submdspan_mapping_result{layout_left_padded<S_static>::mapping(sub_ext, stride(u + 1)), offset} if for a value ufor which u + 1 is the smallest value p larger than zero for which is a unit-stride slice for mapping, the following conditions are met:
- is a unit-stride slice for mapping; and
- for each k in the range [u + 1, u + SubExtents::rank() - 1),is_convertible_v<, full_extent_t> is true; and
- for k equal to u + SubExtents::rank() - 1, is a unit-stride slice for mapping;
where S_static is: - dynamic_extent, if static-padding-stride is dynamic_extent orstatic_extent(k) is dynamic_extentfor any k in the range [1, u + 1),
- otherwise, the product of static-padding-stride and all values static_extent(k) for k in the range [1, u + 1);
- otherwise,submdspan_mapping_result{layout_stride::mapping(sub_ext, sub_strides), offset}
23.7.3.7.6.6 layout_right_padded specialization of submdspan_mapping [mdspan.sub.map.rightpad]
template<class Extents> template<class... SliceSpecifiers> constexpr auto layout_right_padded::mapping<Extents>::submdspan-mapping-impl( SliceSpecifiers... slices) const -> _see below_;
Returns:
- submdspan_mapping_result{*this, 0}, if rank_ == 0 is true;
- otherwise,submdspan_mapping_result{layout_right::mapping(sub_ext), offset},
if rank_ == 1 is true orSubExtents::rank() == 0 is true; - otherwise,submdspan_mapping_result{layout_right::mapping(sub_ext), offset}, if
- SubExtents::rank() == 1 is true and
- for k equal to rank_ - 1, is a unit-stride slice for mapping;
- otherwise,submdspan_mapping_result{layout_right_padded<S_static>::mapping(sub_ext, stride(rank_ - u - 2)), offset} if for a value ufor which rank_ - u - 2is the largest value p smaller than rank_ - 1for which is a unit-stride slice for mapping, the following conditions are met:
- for k equal to rank_ - 1, is a unit-stride slice for mapping; and
- for each k in the range [rank_ - SubExtents::rank() - u + 1, rank_ - u - 1)),is_convertible_v<, full_extent_t> is true; and
- for k equal to rank_ - SubExtents::rank() - u,
is a unit-stride slice for mapping;
and where S_static is: - dynamic_extentif static-padding-stride is dynamic_extent or for any k in the range [rank_ - u - 1, rank_ - 1)static_extent(k) is dynamic_extent,
- otherwise, the product of static-padding-stride and all values static_extent(k)with k in the range [rank_ - u - 1, rank_ - 1);
- otherwise,submdspan_mapping_result{layout_stride::mapping(sub_ext, sub_strides), offset}