std::full_extent, std::full_extent_t
From cppreference.com
| ヘッダー <mdspan> で定義 |
||
| struct full_extent_t { explicit full_extent_t() = default; }; |
(1) | (C++26以降) |
| inline constexpr std::full_extent_t full_extent {}; |
(2) | (C++26以降) |
1) クラス
std::full_extent_tは、std::submdspanで使用できるスライス指定子型です。2) (1)の対応する
std::full_extentインスタンスは、std::submdspanで指定されたエクステントのインデックスのフルレンジを示すスライス指定子です。[編集] 例
このコードを実行
#include <mdspan> #include <print> void print(auto view) { static_assert(view.rank() <= 2); if constexpr (view.rank() == 2) { for (std::size_t i = 0; i != view.extent(0); ++i) { for (std::size_t j = 0; j != view.extent(1); ++j) std::print("{} ", view[i, j]); std::println(); } } else if constexpr (view.rank() == 1) { for (std::size_t i = 0; i != view.extent(0); ++i) std::print("{} ", view[i]); std::println(); } else std::println("{}", view[]); std::println(); } int main() { const char letters []{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'}; const std::mdspan view(letters, 3, 3); print(view); print(std::submdspan(view, std::full_extent, std::full_extent)); print(std::submdspan(view, std::full_extent, 1)); print(std::submdspan(view, 1, std::full_extent)); print(std::submdspan(view, 2, 1)); }
実行結果の例
A B C D E F G H I A B C D E F G H I B E H D E F H
[編集] 関連項目
| (C++26) |
既存の mdspan のサブセットのビューを返す(function template) |