Files
2025-10-25 03:02:53 +03:00

42 lines
1.4 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[range.zip.overview]
# 25 Ranges library [[ranges]](./#ranges)
## 25.7 Range adaptors [[range.adaptors]](range.adaptors#range.zip.overview)
### 25.7.25 Zip view [[range.zip]](range.zip#overview)
#### 25.7.25.1 Overview [range.zip.overview]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L11340)
zip_view takes any number of views and
produces a view of tuples of references
to the corresponding elements of the constituent views[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L11346)
The name views::zip denotes
a customization point object ([[customization.point.object]](customization.point.object "16.3.3.3.5Customization Point Object types"))[.](#2.sentence-1)
Given a pack of subexpressions Es...,
the expression views::zip(Es...) is expression-equivalent to
- [(2.1)](#2.1)
auto(views::empty<tuple<>>) if Es is an empty pack,
- [(2.2)](#2.2)
otherwise, zip_view<views::all_t<decltype((Es))>...>(Es...)[.](#2.sentence-2)
[*Example [1](#example-1)*: vector v = {1, 2};
list l = {'a', 'b', 'c'};
auto z = views::zip(v, l);
range_reference_t<decltype(z)> f = z.front(); // f is a tuple<int&, char&>// that refers to the first element of v and lfor (auto&& [x, y] : z) { cout << '(' << x << ", " << y << ") "; // prints (1, a) (2, b)} — *end example*]