namespace std {
template <class Dst, class T = Dst::value_type>
constexpr void fill(const Dst& dst, const T& value); // (1) C++29
template <class ExecutionPolicy, class Dst, class T = Dst::value_type>
void fill(ExecutionPolicy&& policy,
const Dst& dst, const T& value); // (2) C++29
}
概要
多次元配列ビューstd::mdspanの全要素に、指定した値を代入する。
- (1) : 各要素へ順次代入する
- (2) : 指定した実行ポリシーによって並列に代入する
テンプレートパラメータ制約
Dstがmdspanの特殊化であることis_assignable_v<typename Dst::reference, const T&>がtrueであること
効果
dstの各要素へvalueを代入する。
例
#include <mdspan>
#include <iostream>
int main()
{
double a[6] = {};
std::mdspan<double, std::extents<std::size_t, 2, 3>> m{a};
std::fill(m, 1.5);
for (double x : a) {
std::cout << x << ' ';
}
std::cout << std::endl;
}
このコードはC++29の規則のもとでは適格だが、2026年9月時点で本関数を実装した処理系はない。
出力
1.5 1.5 1.5 1.5 1.5 1.5
バージョン
言語
- C++29
処理系
- Clang: ??
- GCC: ??
- Visual C++: ??
関連項目
copystd::mdspanstd::fill()(イテレータ範囲に対する充填)