Files
cppdraft_translate/cppdraft/range/zip/overview.md
2025-10-25 03:02:53 +03:00

1.4 KiB
Raw Blame History

[range.zip.overview]

25 Ranges library [ranges]

25.7 Range adaptors [range.adaptors]

25.7.25 Zip view [range.zip]

25.7.25.1 Overview [range.zip.overview]

1

#

zip_view takes any number of views and produces a view of tuples of references to the corresponding elements of the constituent views.

2

#

The name views::zip denotes a customization point object ([customization.point.object]).

Given a pack of subexpressions Es..., the expression views::zip(Es...) is expression-equivalent to

auto(views::empty<tuple<>>) if Es is an empty pack,

otherwise, zip_view<views::all_t<decltype((Es))>...>(Es...).

[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]