最終更新日時(UTC):
が更新

履歴 編集

function
<mdspan>

std::layout_right::mapping::コンストラクタ(C++23)

constexpr mapping() noexcept = default;  // (1)

constexpr mapping(const mapping&) noexcept = default;  // (2)

constexpr mapping(const extents_type& e) noexcept;  // (3)

template<class OtherExtents>
constexpr explicit(!is_convertible_v<OtherExtents, extents_type>)
  mapping(const mapping<OtherExtents>& other) noexcept;  // (4)

template<class OtherExtents>
constexpr explicit(!is_convertible_v<OtherExtents, extents_type>)
  mapping(const layout_left::mapping<OtherExtents>& other) noexcept;  // (5)

template<class OtherExtents>
constexpr explicit(extents_type::rank() > 0)
  mapping(const layout_stride::mapping<OtherExtents>& other) noexcept;  // (6)

概要

  • (1) : デフォルトコンストラクタ
  • (2) : コピーコンストラクタ
  • (3) : extentsからの変換コンストラクタ
  • (4) : 他layout_right::mappingからの変換コンストラクタ
  • (5) : layout_left::mappingからの変換コンストラクタ
  • (6) : layout_stride::mappingからの変換コンストラクタ

テンプレートパラメータ制約

事前条件

効果

例外

投げない

explicitになる条件

#include <cassert>
#include <array>
#include <mdspan>

using Ext3x4 = std::extents<size_t, 3, 4>;
using Ext3xN = std::extents<size_t, 3, std::dynamic_extent>;

int main()
{
  // (1) : デフォルトコンストラクタ
  {
    std::layout_right::mapping<Ext3x4> map1_3x4;
    std::layout_right::mapping<Ext3xN> map1_3xN;
    assert(map1_3x4.required_span_size() == 12);
    assert(map1_3xN.required_span_size() == 0);
  }
  // (2) : コピーコンストラクタ
  {
    std::layout_right::mapping<Ext3xN> map2_a;
    std::layout_right::mapping<Ext3xN> map2_b = map2_a;
    assert(map2_a == map2_b);
  }
  // (3) : extentsからの変換コンストラクタ
  {
    Ext3xN ext{4};
    std::layout_right::mapping<Ext3xN> map3 = ext;
    assert(map3.extents() == ext);
  }
  // (4) : layout_right::mappingからの変換コンストラクタ
  {
    std::layout_right::mapping<Ext3x4> map4_3x4;
    std::layout_right::mapping<Ext3xN> map4_3xN = map4_3x4;
    assert(map4_3x4 == map4_3xN);
  }
  // (5) : layout_left::mappingからの変換コンストラクタ
  {
    using Ext1D = std::dextents<size_t, 1>;
    std::layout_left::mapping<Ext1D>  src5{Ext1D{5}};
    std::layout_right::mapping<Ext1D> dst5 = src5;
  }
  // (6) : layout_stride::mappingからの変換コンストラクタ
  {
    std::array strides{4, 1};
    std::layout_stride::mapping<Ext3x4> src6{{}, strides};
    std::layout_right::mapping<Ext3x4>  dst6{src6};  // (explicit)
  }
}

出力

バージョン

言語

  • C++23

処理系

関連項目

参照