constexpr mapping() noexcept; // (1)
constexpr mapping(const mapping&) noexcept = default; // (2)
template<class OtherIndexType>
constexpr mapping(const extents_type& e, span<OtherIndexType, rank_> s) noexcept; // (3)
template<class OtherIndexType>
constexpr mapping(const extents_type& e, const array<OtherIndexType, rank_>& s) noexcept; // (4)
template<class StridedLayoutMapping>
constexpr explicit(see below) mapping(const StridedLayoutMapping& other) noexcept; // (5)
概要
- (1) : デフォルトコンストラクタ
- (2) : コピーコンストラクタ
- (3), (4) :
extents
とストライド幅から構築(定数rank_
は次元数) - (5) : レイアウトマッピングからの変換コンストラクタ
テンプレートパラメータ制約
- (3), (4) :
is_convertible_v<const OtherIndexType&, index_type>
がtrue
、かつis_nothrow_constructible_v<index_type, const OtherIndexType&>
がtrue
であること。
- (5) :
layout-mapping-alike<StridedLayoutMapping>
を満たすis_constructible_v<extents_type, typename StridedLayoutMapping::extents_type> == true
StridedLayoutMapping::is_always_unique() == true
StridedLayoutMapping::is_always_strided() == true
事前条件
- (1) :
layout_right::mapping<extents_type>().required_span_size()
を、index_type
型で表現できること。 - (3), (4) :
- 半開区間
[0, rank_)
の全てのi
に対して、s[i]
をindex_type
へ変換した結果が0
より大きいこと。 REQUIRED-SPAN-SIZE(e, s)
をindex_type
型で表現できること。rank_ > 0
のとき、半開区間[1, rank_)
の全てのi
に対してj = i-1
としてs[Pi] >= s[Pj] * e.extents(Pj)
を満たすの整数値の組合せP
が存在すること。
- 半開区間
- (5) :
StridedLayoutMapping
がレイアウトマッピングポリシーを満たすextents()
の全ての次元r
に対してother.stride(r) > 0
other.required_span_size()
をindex_type
型で表現できることOFFSET(other) == 0
効果
- (1) :
extents_type()
でextents_
を直接非リスト初期化し、全ての次元d
に対してlayout_right::mapping<extents_type>().stride(d)
でstrides_[d]
を直接非リスト初期化する。 - (3), (4) :
e
でextents_
を直接非リスト初期化し、全ての次元d
に対してas_const(s[d])
でstrides_[d]
を直接非リスト初期化する。 - (5) :
other.extents()
でextents_
を直接非リスト初期化し、全ての次元d
に対してother.stride(d)
でstrides_[d]
を直接非リスト初期化する。
例外
投げない
explicitになる条件
- (5) :
explicit
指定子の式は以下と等価
// C++23
!(is_convertible_v<typename StridedLayoutMapping::extents_type, extents_type> &&
(is-mapping-of<layout_left, StridedLayoutMapping> ||
is-mapping-of<layout_right, StridedLayoutMapping> ||
is-mapping-of<layout_stride, StridedLayoutMapping>))
// C++26
!(is_convertible_v<typename StridedLayoutMapping::extents_type, extents_type> &&
(is-mapping-of<layout_left, StridedLayoutMapping> ||
is-mapping-of<layout_right, StridedLayoutMapping> ||
is-layout-left-padded-mapping-of<StridedLayoutMapping> ||
is-layout-right-padded-mapping-of<StridedLayoutMapping> ||
is-mapping-of<layout_stride, StridedLayoutMapping>))
例
#include <cassert>
#include <array>
#include <span>
#include <mdspan>
using Ext3x4 = std::extents<size_t, 3, 4>;
int main()
{
// (1) : デフォルトコンストラクタ
{
std::layout_stride::mapping<Ext3x4> map1;
std::layout_right::mapping<Ext3x4> map1R;
assert(map1 == map1R);
}
// (2) : コピーコンストラクタ
{
std::layout_stride::mapping<Ext3x4> map2_a;
std::layout_stride::mapping<Ext3x4> map2_b = map2_a;
assert(map2_a == map2_b);
}
// (3) : extentsとストライド幅(span)による構築
{
int strides[] = {4, 1};
std::layout_stride::mapping<Ext3x4> map3{Ext3x4{}, std::span(strides)};
assert(map3.stride(0) == 4);
assert(map3.stride(1) == 1);
}
// (4) : extentsとストライド幅(array)による構築
{
std::array strides{4, 1};
std::layout_stride::mapping<Ext3x4> map4{Ext3x4{}, strides};
assert(map4.stride(0) == 4);
assert(map4.stride(1) == 1);
}
// (5) : レイアウトマッピングからの変換コンストラクタ
{
std::layout_left::mapping<Ext3x4> map5L;
std::layout_stride::mapping<Ext3x4> map5 = map5L;
assert(map5 == map5L);
}
}
出力
バージョン
言語
- C++23
処理系
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??