42 lines
1.4 KiB
Markdown
42 lines
1.4 KiB
Markdown
[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.5 Customization 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*]
|