constexpr auto begin(); // (1) C++23
constexpr auto begin() const
requires range<const InnerView> &&
regular_invocable<
const F&,
range_reference_t<const Views>...
>; // (2) C++23
概要
先頭を指すイテレータを取得する。
効果
- (1) :
return iterator<false>(*this, zip_.begin());
- (2) :
return iterator<true>(*this, zip_.begin());
ここで、iterator
はzip_transform_view
の内部で定義される説明専用のイテレータクラスであり、InnerView
は説明専用のzip_view<Views...>
である。
例
#include <ranges>
#include <vector>
#include <list>
#include <iostream>
int main() {
std::vector<int> v = {1, 2, 3};
std::list<char> l = {'a', 'b', 'c'};
auto f = [](int n, char c) { return std::pair{n * 10, c}; };
std::ranges::zip_transform_view ztv(f, v, l);
auto it = ztv.begin();
// 最初の要素(変換結果)
auto [n, c] = *it;
std::cout << n << ", " << c << std::endl;
// 次の要素へ
++it;
auto [n2, c2] = *it;
std::cout << n2 << ", " << c2 << std::endl;
}
出力
10, a
20, b
バージョン
言語
- C++23
処理系
- Clang: 19 ✅
- GCC: 13 ✅
- Visual C++: 2022 Update 6 ✅